]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/58794 (ICE in set_lattice_value, at tree-ssa-ccp.c:455 on...
authorRichard Biener <rguenther@suse.de>
Mon, 21 Oct 2013 13:33:29 +0000 (13:33 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 21 Oct 2013 13:33:29 +0000 (13:33 +0000)
2013-10-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/58794
* fold-const.c (operand_equal_p): Compare FIELD_DECL operand
of COMPONENT_REFs with OEP_CONSTANT_ADDRESS_OF left in place.

* c-c++-common/torture/pr58794-1.c: New testcase.
* c-c++-common/torture/pr58794-2.c: Likewise.

From-SVN: r203891

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/torture/pr58794-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/pr58794-2.c [new file with mode: 0644]

index 99b921abfbd21eb806771408d9131900ccec88e4..389c9afd9d506bd3fc913030c54365046e4a63a5 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58794
+       * fold-const.c (operand_equal_p): Compare FIELD_DECL operand
+       of COMPONENT_REFs with OEP_CONSTANT_ADDRESS_OF left in place.
+
 2013-10-21  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/58742
index 2a184109ea1fcc1d6cbbf587f8247a12ecd2b57c..0f9454d4be6e6904e0e40f28a46383bec246d15d 100644 (file)
@@ -2715,10 +2715,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
        case COMPONENT_REF:
          /* Handle operand 2 the same as for ARRAY_REF.  Operand 0
             may be NULL when we're called to compare MEM_EXPRs.  */
-         if (!OP_SAME_WITH_NULL (0))
+         if (!OP_SAME_WITH_NULL (0)
+             || !OP_SAME (1))
            return 0;
          flags &= ~OEP_CONSTANT_ADDRESS_OF;
-         return OP_SAME (1) && OP_SAME_WITH_NULL (2);
+         return OP_SAME_WITH_NULL (2);
 
        case BIT_FIELD_REF:
          if (!OP_SAME (0))
index 6add22c389ebb7fbaa72301107def4e8a3bc3c59..0293a771ab055ad38e77b10d583e8a1f99b3514e 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58794
+       * c-c++-common/torture/pr58794-1.c: New testcase.
+       * c-c++-common/torture/pr58794-2.c: Likewise.
+
 2013-10-21  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/58742
diff --git a/gcc/testsuite/c-c++-common/torture/pr58794-1.c b/gcc/testsuite/c-c++-common/torture/pr58794-1.c
new file mode 100644 (file)
index 0000000..175629f
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+
+struct S0
+{
+  int f;
+};
+
+struct S1
+{
+  struct S0 f1;
+  volatile int f2;
+};
+
+struct S2
+{
+  struct S1 g;
+} a, b; 
+
+static int *c[1][2] = {{0, (int *)&a.g.f2}};
+static int d; 
+
+int
+main ()
+{
+  for (d = 0; d < 1; d++)
+    for (b.g.f1.f = 0; b.g.f1.f < 1; b.g.f1.f++)
+      *c[b.g.f1.f][d + 1] = 0;
+  return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/torture/pr58794-2.c b/gcc/testsuite/c-c++-common/torture/pr58794-2.c
new file mode 100644 (file)
index 0000000..7677988
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+struct S 
+{
+  volatile int f;
+} a;
+
+unsigned int b;
+
+static int *c[1][2] = {{0, (int *)&a.f}};
+static unsigned int d;
+
+int 
+main ()
+{
+  for (; d < 1; d++)
+    for (; b < 1; b++)
+      *c[b][d + 1] = 0;
+
+  return 0;
+}