summaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2000-09-19 13:39:10 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2000-09-19 13:39:10 +0000
commitf60bd4a6c78723fa75f98e00e069659e4b5dc7b3 (patch)
tree923b7f25e39f6b01258cfeb1721e12e7bd3e602e /gcc/stmt.c
parent9dce90467f4a34684fd33d78b43d0d97c0b2496f (diff)
downloadgcc-f60bd4a6c78723fa75f98e00e069659e4b5dc7b3.tar.gz
* stmt.c (expand_expr_stmt): Only call warn_if_unused_value
if the tree has side effects. (warn_if_unused_value): Do not warn about void constructs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36532 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r--gcc/stmt.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 11a713225e0..2892d340b89 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1908,12 +1908,14 @@ expand_expr_stmt (exp)
except inside a ({...}) where they may be useful. */
if (expr_stmts_for_value == 0 && exp != error_mark_node)
{
- if (! TREE_SIDE_EFFECTS (exp)
- && (extra_warnings || warn_unused_value)
- && !(TREE_CODE (exp) == CONVERT_EXPR
- && VOID_TYPE_P (TREE_TYPE (exp))))
- warning_with_file_and_line (emit_filename, emit_lineno,
- "statement with no effect");
+ if (! TREE_SIDE_EFFECTS (exp))
+ {
+ if ((extra_warnings || warn_unused_value)
+ && !(TREE_CODE (exp) == CONVERT_EXPR
+ && VOID_TYPE_P (TREE_TYPE (exp))))
+ warning_with_file_and_line (emit_filename, emit_lineno,
+ "statement with no effect");
+ }
else if (warn_unused_value)
warn_if_unused_value (exp);
}
@@ -1978,6 +1980,12 @@ warn_if_unused_value (exp)
if (TREE_USED (exp))
return 0;
+ /* Don't warn about void constructs. This includes casting to void,
+ void function calls, and statement expressions with a final cast
+ to void. */
+ if (VOID_TYPE_P (TREE_TYPE (exp)))
+ return 0;
+
switch (TREE_CODE (exp))
{
case PREINCREMENT_EXPR:
@@ -2023,9 +2031,6 @@ warn_if_unused_value (exp)
case NOP_EXPR:
case CONVERT_EXPR:
case NON_LVALUE_EXPR:
- /* Don't warn about values cast to void. */
- if (VOID_TYPE_P (TREE_TYPE (exp)))
- return 0;
/* Don't warn about conversions not explicit in the user's program. */
if (TREE_NO_UNUSED_WARNING (exp))
return 0;