re PR tree-optimization/56635 (internal compiler error: in find_lattice_value, at...
authorJakub Jelinek <jakub@redhat.com>
Mon, 18 Mar 2013 13:01:49 +0000 (14:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 18 Mar 2013 13:01:49 +0000 (14:01 +0100)
PR tree-optimization/56635
* fold-const.c (operand_equal_p): For MEM_REF and TARGET_MEM_REF,
require types_compatible_p types.

* g++.dg/torture/pr56635.C: New test.

From-SVN: r196781

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr56635.C [new file with mode: 0644]

index 0bae8e6482537237d7635df1c8e0d6473328f0fc..de91c80b3f78e8ab19500753869918ee4b273a05 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/56635
+       * fold-const.c (operand_equal_p): For MEM_REF and TARGET_MEM_REF,
+       require types_compatible_p types.
+
 2013-03-18  Nick Clifton  <nickc@redhat.com>
 
        * config/stormy16/stormy16.c (xstormy16_expand_prologue): Remove
index 26cfc0e83e430c2a71c6c242a00602cab5b40e36..de7117e8e8710b94aaee8fa18856c29fe97363bb 100644 (file)
@@ -2572,13 +2572,14 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
          flags &= ~OEP_CONSTANT_ADDRESS_OF;
          /* Require equal access sizes, and similar pointer types.
             We can have incomplete types for array references of
-            variable-sized arrays from the Fortran frontent
-            though.  */
+            variable-sized arrays from the Fortran frontend
+            though.  Also verify the types are compatible.  */
          return ((TYPE_SIZE (TREE_TYPE (arg0)) == TYPE_SIZE (TREE_TYPE (arg1))
                   || (TYPE_SIZE (TREE_TYPE (arg0))
                       && TYPE_SIZE (TREE_TYPE (arg1))
                       && operand_equal_p (TYPE_SIZE (TREE_TYPE (arg0)),
                                           TYPE_SIZE (TREE_TYPE (arg1)), flags)))
+                 && types_compatible_p (TREE_TYPE (arg0), TREE_TYPE (arg1))
                  && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg0, 1)))
                      == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg1, 1))))
                  && OP_SAME (0) && OP_SAME (1));
index 20b206ae4603986484c1157ae22476ec59ad390e..4240674fcd115821e8f857ff553afe92e4020197 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/56635
+       * g++.dg/torture/pr56635.C: New test.
+
 2013-03-18  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/3713
diff --git a/gcc/testsuite/g++.dg/torture/pr56635.C b/gcc/testsuite/g++.dg/torture/pr56635.C
new file mode 100644 (file)
index 0000000..53d6bb9
--- /dev/null
@@ -0,0 +1,17 @@
+// PR tree-optimization/56635
+// { dg-do compile }
+
+struct A { _Complex double a; };
+
+void
+foo (A **x, A **y)
+{
+  A r;
+  if (__real__ x[0]->a)
+    {
+      r.a = y[0]->a / x[0]->a;
+      **x = r;
+    }
+  else
+    **x = **y;
+}