+2005-04-27 Joseph S. Myers <joseph@codesourcery.com>
+
+ 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.
+
2005-04-27 Caroline Tice <ctice@apple.com>
* bb-reorder.c (find_rarely_executed_basic_blocks_and_crossing_edges):
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
+2005-04-27 Joseph S. Myers <joseph@codesourcery.com>
+
+ PR c/21159
+ * gcc.dg/void-cast-1.c: New test.
+
2005-04-27 Paolo Bonzini <bonzini@gnu.org>
* gcc.dg/tree-ssa/gen-vect-25.c: Make more portable.
--- /dev/null
+/* Don't warn where the left-hand side of a comma expression is a
+ comma expression whose right-hand side is cast to void. Bug
+ 21159. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+int a, b, c, d;
+int e(void) { return (void)a, b; }
+int f(void) { return (void)a, (void)b, c; }
+int g(void) { return (void)a, (void)b, (void)c, d; }