Commit e14a6540 by Joseph Myers Committed by Joseph Myers

c-typeck.c (build_compound_expr): Correct logic in last change.

	* c-typeck.c (build_compound_expr): Correct logic in last change.

testsuite:
	* gcc.dg/void-cast-2.c: New test.

From-SVN: r98901
parent c1bc6ca8
2005-04-28 Joseph S. Myers <joseph@codesourcery.com>
* c-typeck.c (build_compound_expr): Correct logic in last change.
2005-04-27 James E. Wilson <wilson@specifixinc.com> 2005-04-27 James E. Wilson <wilson@specifixinc.com>
* config/ia64/ia64.c (update_set_flags): Delete ppred and pcond * config/ia64/ia64.c (update_set_flags): Delete ppred and pcond
......
...@@ -3108,12 +3108,13 @@ build_compound_expr (tree expr1, tree expr2) ...@@ -3108,12 +3108,13 @@ build_compound_expr (tree expr1, tree expr2)
/* The left-hand operand of a comma expression is like an expression /* The left-hand operand of a comma expression is like an expression
statement: with -Wextra or -Wunused, we should warn if it doesn't have statement: with -Wextra or -Wunused, we should warn if it doesn't have
any side-effects, unless it was explicitly cast to (void). */ any side-effects, unless it was explicitly cast to (void). */
if (warn_unused_value if (warn_unused_value)
&& !VOID_TYPE_P (TREE_TYPE (expr1)))
{ {
if (TREE_CODE (expr1) == CONVERT_EXPR) if (VOID_TYPE_P (TREE_TYPE (expr1))
&& TREE_CODE (expr1) == CONVERT_EXPR)
; /* (void) a, b */ ; /* (void) a, b */
else if (TREE_CODE (expr1) == COMPOUND_EXPR else if (VOID_TYPE_P (TREE_TYPE (expr1))
&& TREE_CODE (expr1) == COMPOUND_EXPR
&& TREE_CODE (TREE_OPERAND (expr1, 1)) == CONVERT_EXPR) && TREE_CODE (TREE_OPERAND (expr1, 1)) == CONVERT_EXPR)
; /* (void) a, (void) b, c */ ; /* (void) a, (void) b, c */
else else
......
2005-04-28 Joseph S. Myers <joseph@codesourcery.com>
* gcc.dg/void-cast-2.c: New test.
2005-04-27 Joseph S. Myers <joseph@codesourcery.com> 2005-04-27 Joseph S. Myers <joseph@codesourcery.com>
PR c/21159 PR c/21159
......
/* Test further cases of warnings for comma expressions, with and
without casts to void. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wall" } */
int a, b, c, d;
int e(void) { return (char)a, b; } /* { dg-warning "warning: left-hand operand of comma expression has no effect" } */
int f(void) { return (a ? (void)b : (void)c), d; } /* { dg-warning "warning: left-hand operand of comma expression has no effect" } */
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