]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/46160 (ICE with volatile structure and enum)
authorJakub Jelinek <jakub@redhat.com>
Thu, 11 Nov 2010 20:39:25 +0000 (21:39 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 11 Nov 2010 20:39:25 +0000 (21:39 +0100)
2010-11-11  Jakub Jelinek  <jakub@redhat.com>

Backport from mainline
2010-11-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/46160
* cp-gimplify.c (cp_gimplify_expr): Drop volatile INDIRECT_REFs
on the RHS to avoid infinite recursion with gimplify_expr.

* g++.dg/opt/empty2.C: New test.

From-SVN: r166619

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/empty2.C [new file with mode: 0644]

index 904a7026235360cffd6e1808fb6ef43cbf55e47b..0eeb05ace3d06fc95c59b7832c44a79cff3f7a23 100644 (file)
@@ -1,3 +1,12 @@
+2010-11-11  Jakub Jelinek  <jakub@redhat.com>
+
+       Backport from mainline
+       2010-11-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/46160
+       * cp-gimplify.c (cp_gimplify_expr): Drop volatile INDIRECT_REFs
+       on the RHS to avoid infinite recursion with gimplify_expr.
+
 2010-10-15  Jason Merrill  <jason@redhat.com>
 
        PR c++/45983
index 2e3f11d09466208243d82ee5795128f639084733..d0d8dad4d557fbc598ed117e30addf19a877508b 100644 (file)
@@ -590,6 +590,16 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
            if (!TREE_SIDE_EFFECTS (op1)
                || (DECL_P (op1) && TREE_THIS_VOLATILE (op1)))
              *expr_p = op0;
+           else if (TREE_CODE (op1) == INDIRECT_REF
+                    && TREE_THIS_VOLATILE (op1))
+             {
+               /* Similarly for volatile INDIRECT_REFs on the RHS.  */
+               if (!TREE_SIDE_EFFECTS (TREE_OPERAND (op1, 0)))
+                 *expr_p = op0;
+               else
+                 *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
+                                   TREE_OPERAND (op1, 0), op0);
+             }
            else
              *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
                                op0, op1);
index b629fb960db5c4ed852ae5952f265b587b4d40d6..e549f45a41eae2d297ab1bb5652d45cfb2de6d2d 100644 (file)
@@ -3,6 +3,9 @@
        Backport from mainline
        2010-11-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/46160
+       * g++.dg/opt/empty2.C: New test.
+
        PR tree-optimization/46099
        * gcc.dg/autopar/pr46099.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/opt/empty2.C b/gcc/testsuite/g++.dg/opt/empty2.C
new file mode 100644 (file)
index 0000000..86caa5c
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/46160
+// { dg-do compile }
+
+struct S
+{
+  enum E { A };
+} s;
+volatile S t;
+
+void f (S::E);
+
+void
+g ()
+{
+  volatile S *p = &s;
+  f (p->A);
+  f (t.A);
+}