diff options
author | Joseph Myers <joseph@codesourcery.com> | 2005-08-06 11:31:49 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2005-08-06 11:31:49 +0000 |
commit | 54a3ca7969b05f24742c6321d3337d78fcad1fc9 (patch) | |
tree | 50083463eef147d4518d2138f1a14ce9e8fb18b7 /gcc/c-typeck.c | |
parent | b82ba3c3fe4ee35b4c804a92c6565604d636453b (diff) |
PR c/23113
* stmt.c (warn_if_unused_value): Check TREE_NO_WARNING at start.
Don't handle NOP_EXPR, CONVERT_EXPR and NON_LVALUE_EXPR
specially. Check for side effects only for COND_EXPR.
* c-typeck.c (c_finish_stmt_expr): Mark statement expression
return with TREE_NO_WARNING.
testsuite:
* gcc.dg/Wunused-value-1.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@102805 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c0498955f08..90787305ecf 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -7315,7 +7315,13 @@ c_finish_stmt_expr (tree body) if (last == error_mark_node || (last == BIND_EXPR_BODY (body) && BIND_EXPR_VARS (body) == NULL)) - return last; + { + /* Do not warn if the return value of a statement expression is + unused. */ + if (EXPR_P (last)) + TREE_NO_WARNING (last) = 1; + return last; + } /* Extract the type of said expression. */ type = TREE_TYPE (last); |