diff options
| author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-27 21:41:15 +0000 |
|---|---|---|
| committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-27 21:41:15 +0000 |
| commit | 778e3b560e7e231725b49cab0b886ab2f44f5bff (patch) | |
| tree | ce276778b8df2b8bd816052b690271a7aecc28d3 /gcc/c-typeck.c | |
| parent | 4d0e931faa7ab6bb3ebe39347667b74ffd1c460d (diff) | |
| download | ppe42-gcc-778e3b560e7e231725b49cab0b886ab2f44f5bff.tar.gz ppe42-gcc-778e3b560e7e231725b49cab0b886ab2f44f5bff.zip | |
PR c/21159
* c-typeck.c (build_compound_expr): Don't warn for left-hand side
being a compound expression whose right-hand side is cast to void.
testsuite:
* gcc.dg/void-cast-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98886 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
| -rw-r--r-- | gcc/c-typeck.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index cde90a763d3..281d2b0cf14 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -3109,9 +3109,16 @@ build_compound_expr (tree expr1, tree expr2) statement: with -Wextra or -Wunused, we should warn if it doesn't have any side-effects, unless it was explicitly cast to (void). */ if (warn_unused_value - && !(TREE_CODE (expr1) == CONVERT_EXPR - && VOID_TYPE_P (TREE_TYPE (expr1)))) - warning (0, "left-hand operand of comma expression has no effect"); + && !VOID_TYPE_P (TREE_TYPE (expr1))) + { + if (TREE_CODE (expr1) == CONVERT_EXPR) + ; /* (void) a, b */ + else if (TREE_CODE (expr1) == COMPOUND_EXPR + && TREE_CODE (TREE_OPERAND (expr1, 1)) == CONVERT_EXPR) + ; /* (void) a, (void) b, c */ + else + warning (0, "left-hand operand of comma expression has no effect"); + } } /* With -Wunused, we should also warn if the left-hand operand does have |

