aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2000-11-14 01:51:46 -0800
committerRichard Henderson <rth@gcc.gnu.org>2000-11-14 01:51:46 -0800
commit6f1225504f3c4124fd4ab85edd0db620b14264ac (patch)
tree5ceab0e846550f51138e700c6642807d23e00bbb /gcc
parent0caa3c8e095f903a847e8dfe4d652e9dfac91850 (diff)
downloadgcc-6f1225504f3c4124fd4ab85edd0db620b14264ac.zip
gcc-6f1225504f3c4124fd4ab85edd0db620b14264ac.tar.gz
gcc-6f1225504f3c4124fd4ab85edd0db620b14264ac.tar.bz2
stmt.c (warn_if_unused_value): Don't warn if the expression has side effects.
* stmt.c (warn_if_unused_value): Don't warn if the expression has side effects. From-SVN: r37448
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog3
-rw-r--r--gcc/stmt.c7
2 files changed, 7 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f82e04a..d9794e1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
2000-11-14 Richard Henderson <rth@redhat.com>
+ * stmt.c (warn_if_unused_value): Don't warn if the expression
+ has side effects.
+
* c-typeck.c (c_sizeof): Fold result to c_size_type_node.
(c_sizeof_nowarn, c_alignof, c_alignof_expr): Likewise.
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 4e42e69..82a390d 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -2004,9 +2004,6 @@ warn_if_unused_value (exp)
case TRY_CATCH_EXPR:
case WITH_CLEANUP_EXPR:
case EXIT_EXPR:
- /* We don't warn about COND_EXPR because it may be a useful
- construct if either arm contains a side effect. */
- case COND_EXPR:
return 0;
case BIND_EXPR:
@@ -2067,6 +2064,10 @@ warn_if_unused_value (exp)
&& TREE_THIS_VOLATILE (exp))
return 0;
+ /* If this is an expression with side effects, don't warn. */
+ if (TREE_SIDE_EFFECTS (exp))
+ return 0;
+
/* If this is an expression which has no operands, there is no value
to be unused. There are no such language-independent codes,
but front ends may define such. */