OSDN Git Service

2008-08-28 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 29 Aug 2008 00:06:19 +0000 (00:06 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 29 Aug 2008 00:06:19 +0000 (00:06 +0000)
            Andrew Pinski  <pinskia@gcc.gnu.org>

PR 18050
* c-common.c (verify_tree): Fix handling of ADDR_EXPR.
testsuite/
* gcc.dg/Wsequence-point-pr18050.c: New.
* g++.dg/warn/Wsequence-point-pr18050.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139742 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wsequence-point-pr18050.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wsequence-point-pr18050.c [new file with mode: 0644]

index 7ad5729..5b0147c 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-28  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+            Andrew Pinski  <pinskia@gcc.gnu.org>
+
+       PR 18050
+       * c-common.c (verify_tree): Fix handling of ADDR_EXPR.
+
 2008-08-28  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * gtrh-posix.h: Fix uses of _POSIX_TIMEOUTS per the normal Posix
index e0a0829..4493a4b 100644 (file)
@@ -2189,6 +2189,13 @@ verify_tree (tree x, struct tlist **pbefore_sp, struct tlist **pno_sp,
        return;
       }
 
+    case ADDR_EXPR:
+      x = TREE_OPERAND (x, 0);
+      if (DECL_P (x))
+       return;
+      writer = 0;
+      goto restart;
+
     default:
       /* For other expressions, simply recurse on their operands.
         Manual tail recursion for unary expressions.
index 19816c0..ccc35c8 100644 (file)
@@ -1,3 +1,10 @@
+2008-08-28  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+            Andrew Pinski  <pinskia@gcc.gnu.org>
+
+       PR 18050
+       * gcc.dg/Wsequence-point-pr18050.c: New.
+       * g++.dg/warn/Wsequence-point-pr18050.C: New.
+
 2008-08-28  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/37260
diff --git a/gcc/testsuite/g++.dg/warn/Wsequence-point-pr18050.C b/gcc/testsuite/g++.dg/warn/Wsequence-point-pr18050.C
new file mode 100644 (file)
index 0000000..63aecd0
--- /dev/null
@@ -0,0 +1,24 @@
+/* PR 18050 : bogus warning with -Wsequence-point */
+/* { dg-do compile } */
+/* { dg-options "-Wsequence-point" } */
+
+struct x
+{
+  int i;
+};
+void bar(struct x*, int *);
+
+void foo(struct x *y)
+{
+  bar(y++, &y->i); /* { dg-warning "operation on 'y' may be undefined" } */
+}
+
+void zz(int a, int *b)
+{
+  *b = a;
+}
+
+void baz(void) {
+  int a = 5;
+  zz(++a, &a);  /* { dg-bogus "operation on 'a' may be undefined" } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wsequence-point-pr18050.c b/gcc/testsuite/gcc.dg/Wsequence-point-pr18050.c
new file mode 100644 (file)
index 0000000..63aecd0
--- /dev/null
@@ -0,0 +1,24 @@
+/* PR 18050 : bogus warning with -Wsequence-point */
+/* { dg-do compile } */
+/* { dg-options "-Wsequence-point" } */
+
+struct x
+{
+  int i;
+};
+void bar(struct x*, int *);
+
+void foo(struct x *y)
+{
+  bar(y++, &y->i); /* { dg-warning "operation on 'y' may be undefined" } */
+}
+
+void zz(int a, int *b)
+{
+  *b = a;
+}
+
+void baz(void) {
+  int a = 5;
+  zz(++a, &a);  /* { dg-bogus "operation on 'a' may be undefined" } */
+}