diff options
author | Jakub Jelinek <jakub@redhat.com> | 2002-01-04 22:03:20 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2002-01-04 22:03:20 +0100 |
commit | b0832fe1f38ce3553cb4d3b91b4821565c9d0d36 (patch) | |
tree | 39b333f5be357db96e4a98270b060aeefbef3de7 /gcc/stmt.c | |
parent | 81550d0e5fea4bf706390c9cd84b14d6f8d8fe3e (diff) | |
download | gcc-b0832fe1f38ce3553cb4d3b91b4821565c9d0d36.zip gcc-b0832fe1f38ce3553cb4d3b91b4821565c9d0d36.tar.gz gcc-b0832fe1f38ce3553cb4d3b91b4821565c9d0d36.tar.bz2 |
tree.h (expand_expr_stmt_value): Add maybe_last argument.
* tree.h (expand_expr_stmt_value): Add maybe_last argument.
* c-common.h (genrtl_expr_stmt_value): Likewise.
* stmt.c (expand_expr_stmt): Pass 1 as maybe_last.
(expand_expr_stmt_value): Add maybe_last argument.
Don't warn about statement with no effect if it is the last statement
in expression statement.
* c-semantics.c (genrtl_expr_stmt): Pass 1 as maybe_last.
(genrtl_expr_stmt_value): Add maybe_last argument, pass it down to
expand_expr_stmt_value.
(expand_stmt) [EXPR_STMT]: Pass 1 as maybe_last to
genrtl_expr_stmt_value if t is the last EXPR_STMT in its scope.
* expr.c (expand_expr) [LABELED_BLOCK_EXPR, LOOP_EXPR]: Pass 1
as maybe_last to expand_expr_stmt_value.
* gcc.dg/20020104-1.c: New test.
From-SVN: r48541
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r-- | gcc/stmt.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -2190,7 +2190,7 @@ void expand_expr_stmt (exp) tree exp; { - expand_expr_stmt_value (exp, -1); + expand_expr_stmt_value (exp, -1, 1); } /* Generate RTL to evaluate the expression EXP. WANT_VALUE tells @@ -2199,9 +2199,9 @@ expand_expr_stmt (exp) deprecated, and retained only for backward compatibility. */ void -expand_expr_stmt_value (exp, want_value) +expand_expr_stmt_value (exp, want_value, maybe_last) tree exp; - int want_value; + int want_value, maybe_last; { rtx value; tree type; @@ -2211,8 +2211,10 @@ expand_expr_stmt_value (exp, want_value) /* If -W, warn about statements with no side effects, except for an explicit cast to void (e.g. for assert()), and - except inside a ({...}) where they may be useful. */ - if (! want_value && exp != error_mark_node) + except for last statement in ({...}) where they may be useful. */ + if (! want_value + && (expr_stmts_for_value == 0 || ! maybe_last) + && exp != error_mark_node) { if (! TREE_SIDE_EFFECTS (exp)) { |