Commit 7133e992 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/4697 (Warning 'value computed is not used' missing)

	PR c/4697:
	* stmt.c (warn_if_unused_value): Move side effects test once more.

	* gcc.dg/20020220-2.c: New test.

From-SVN: r49937
parent e2ec05a6
2002-02-21 Jakub Jelinek <jakub@redhat.com>
PR c/4697:
* stmt.c (warn_if_unused_value): Move side effects test once more.
2002-02-20 Torbjorn Granlund <tege@swox.com>
* config/avr/avr.md: Add more patterns for mized-mode add and subtract
......
......@@ -2303,10 +2303,6 @@ warn_if_unused_value (exp)
if (VOID_TYPE_P (TREE_TYPE (exp)))
return 0;
/* If this is an expression with side effects, don't warn. */
if (TREE_SIDE_EFFECTS (exp))
return 0;
switch (TREE_CODE (exp))
{
case PREINCREMENT_EXPR:
......@@ -2366,7 +2362,7 @@ warn_if_unused_value (exp)
|| TREE_CODE (tem) == CALL_EXPR)
return 0;
}
goto warn;
goto maybe_warn;
case INDIRECT_REF:
/* Don't warn about automatic dereferencing of references, since
......@@ -2389,7 +2385,11 @@ warn_if_unused_value (exp)
&& TREE_CODE_LENGTH (TREE_CODE (exp)) == 0)
return 0;
warn:
maybe_warn:
/* If this is an expression with side effects, don't warn. */
if (TREE_SIDE_EFFECTS (exp))
return 0;
warning_with_file_and_line (emit_filename, emit_lineno,
"value computed is not used");
return 1;
......
2002-02-21 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/20020220-2.c: New test.
2002-02-20 Alexandre Oliva <aoliva@redhat.com>
* gcc.c-torture/compile/20020110.c: New test.
......
/* PR c/4697
Test whether value computed not used warning is given for compound
expression. */
/* { dg-do compile } */
/* { dg-options "-O2 -Wunused" } */
int b;
int foo (int a)
{
a = a + 1, 5 * b; /* { dg-warning "value computed is not used" } */
return a;
}
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