Commit b0832fe1 by Jakub Jelinek Committed by Jakub Jelinek

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
parent 81550d0e
2002-01-04 Jakub Jelinek <jakub@redhat.com>
* 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.
Fri Jan 4 11:45:05 2002 Jeffrey A Law (law@redhat.com)
* c-common.c (c_expand_start_cond): Expect the IF_STMT node to
......
......@@ -721,7 +721,7 @@ extern void add_c_tree_codes PARAMS ((void));
extern void genrtl_do_pushlevel PARAMS ((void));
extern void genrtl_goto_stmt PARAMS ((tree));
extern void genrtl_expr_stmt PARAMS ((tree));
extern void genrtl_expr_stmt_value PARAMS ((tree, int));
extern void genrtl_expr_stmt_value PARAMS ((tree, int, int));
extern void genrtl_decl_stmt PARAMS ((tree));
extern void genrtl_if_stmt PARAMS ((tree));
extern void genrtl_while_stmt PARAMS ((tree));
......
......@@ -313,18 +313,20 @@ void
genrtl_expr_stmt (expr)
tree expr;
{
genrtl_expr_stmt_value (expr, -1);
genrtl_expr_stmt_value (expr, -1, 1);
}
/* Generate the RTL for EXPR, which is an EXPR_STMT. WANT_VALUE tells
whether to (1) save the value of the expression, (0) discard it or
(-1) use expr_stmts_for_value to tell. The use of -1 is
deprecated, and retained only for backward compatibility. */
deprecated, and retained only for backward compatibility.
MAYBE_LAST is non-zero if this EXPR_STMT might be the last statement
in expression statement. */
void
genrtl_expr_stmt_value (expr, want_value)
genrtl_expr_stmt_value (expr, want_value, maybe_last)
tree expr;
int want_value;
int want_value, maybe_last;
{
if (expr != NULL_TREE)
{
......@@ -334,7 +336,7 @@ genrtl_expr_stmt_value (expr, want_value)
expand_start_target_temps ();
if (expr != error_mark_node)
expand_expr_stmt_value (expr, want_value);
expand_expr_stmt_value (expr, want_value, maybe_last);
if (stmts_are_full_exprs_p ())
expand_end_target_temps ();
......@@ -763,7 +765,10 @@ expand_stmt (t)
break;
case EXPR_STMT:
genrtl_expr_stmt_value (EXPR_STMT_EXPR (t), TREE_ADDRESSABLE (t));
genrtl_expr_stmt_value (EXPR_STMT_EXPR (t), TREE_ADDRESSABLE (t),
TREE_CHAIN (t) == NULL
|| (TREE_CODE (TREE_CHAIN (t)) == SCOPE_STMT
&& TREE_CHAIN (TREE_CHAIN (t)) == NULL));
break;
case DECL_STMT:
......
......@@ -6453,7 +6453,7 @@ expand_expr (exp, target, tmode, modifier)
case LABELED_BLOCK_EXPR:
if (LABELED_BLOCK_BODY (exp))
expand_expr_stmt_value (LABELED_BLOCK_BODY (exp), 0);
expand_expr_stmt_value (LABELED_BLOCK_BODY (exp), 0, 1);
/* Should perhaps use expand_label, but this is simpler and safer. */
do_pending_stack_adjust ();
emit_label (label_rtx (LABELED_BLOCK_LABEL (exp)));
......@@ -6468,7 +6468,7 @@ expand_expr (exp, target, tmode, modifier)
case LOOP_EXPR:
push_temp_slots ();
expand_start_loop (1);
expand_expr_stmt_value (TREE_OPERAND (exp, 0), 0);
expand_expr_stmt_value (TREE_OPERAND (exp, 0), 0, 1);
expand_end_loop ();
pop_temp_slots ();
......
......@@ -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))
{
......
2002-01-04 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/20020104-1.c: New test.
2002-01-04 Hans-Peter Nilsson <hp@bitrange.com>
* gcc.dg/20020103-1.c: Fix typo in target selector.
......
/* Test whether statement with no effect warnings are not given for last
statements inside of statement expression. */
/* { dg-do compile } */
/* { dg-options "-O -Wall" } */
void bar (char *p, char *q);
int main()
{
char foo [32], *p;
({
void *s = (foo);
__builtin_memset (s, '\0', sizeof (foo));
s; /* { dg-warning "no effect" "statement with no effect warning" } */
s; /* { dg-bogus "no effect" "bogus statement with no effect warning" } */
});
p = foo;
p; /* { dg-warning "no effect" "statement with no effect warning" } */
bar (foo, p);
return 0;
}
......@@ -2720,7 +2720,7 @@ extern void expand_fixups PARAMS ((rtx));
extern tree expand_start_stmt_expr PARAMS ((void));
extern tree expand_end_stmt_expr PARAMS ((tree));
extern void expand_expr_stmt PARAMS ((tree));
extern void expand_expr_stmt_value PARAMS ((tree, int));
extern void expand_expr_stmt_value PARAMS ((tree, int, int));
extern int warn_if_unused_value PARAMS ((tree));
extern void expand_decl_init PARAMS ((tree));
extern void clear_last_expr PARAMS ((void));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment