Patchwork [C++] Fix -Wsequence-point with SIZEOF_EXPR (PR c++/57274)

login
register
mail settings
Submitter Jakub Jelinek
Date May 14, 2013, 6:50 p.m.
Message ID <20130514185005.GT1377@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/243800/
State New
Headers show

Comments

Jakub Jelinek - May 14, 2013, 6:50 p.m.
Hi!

Another regression caused by the delayed SIZEOF_EXPR evaluation.
For the purposes of -Wsequence-point warnings we should never
recurse into SIZEOF_EXPR operand, the expressions in there aren't
evaluated there.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8?

2013-05-14  Jakub Jelinek  <jakub@redhat.com>

	PR c++/57274
	* c-common.c (verify_tree): Don't recurse into SIZEOF_EXPR.

	* c-c++-common/Wsequence-point-1.c: New test.


	Jakub
Jason Merrill - May 14, 2013, 8:48 p.m.
Ok.

Jason

Patch

--- gcc/c-family/c-common.c.jj	2013-05-13 09:44:53.000000000 +0200
+++ gcc/c-family/c-common.c	2013-05-14 17:04:59.273912576 +0200
@@ -3032,6 +3032,7 @@  verify_tree (tree x, struct tlist **pbef
   switch (code)
     {
     case CONSTRUCTOR:
+    case SIZEOF_EXPR:
       return;
 
     case COMPOUND_EXPR:
--- gcc/testsuite/c-c++-common/Wsequence-point-1.c.jj	2013-05-14 17:02:55.588608130 +0200
+++ gcc/testsuite/c-c++-common/Wsequence-point-1.c	2013-05-14 17:01:06.000000000 +0200
@@ -0,0 +1,17 @@ 
+/* PR c++/57274 */
+/* { dg-do compile } */
+/* { dg-options "-Wsequence-point" } */
+
+void foo (int, int);
+
+void
+bar (int *x)
+{
+  foo (*x++, sizeof (*x));	/* { dg-bogus "may be undefined" } */
+}
+
+void
+baz (int *x)
+{
+  foo (*x, sizeof (*x++) + sizeof (*x++));	/* { dg-bogus "may be undefined" } */
+}