+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>
* config/ia64/ia64.c (update_set_flags): Delete ppred and pcond
/* 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
any side-effects, unless it was explicitly cast to (void). */
- if (warn_unused_value
- && !VOID_TYPE_P (TREE_TYPE (expr1)))
+ if (warn_unused_value)
{
- if (TREE_CODE (expr1) == CONVERT_EXPR)
+ if (VOID_TYPE_P (TREE_TYPE (expr1))
+ && TREE_CODE (expr1) == CONVERT_EXPR)
; /* (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)
; /* (void) a, (void) b, c */
else
--- /dev/null
+/* 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" } */