re PR middle-end/89779 (internal compiler error: tree check: expected class ‘type...
authorRichard Biener <rguenther@suse.de>
Thu, 21 Mar 2019 14:27:32 +0000 (14:27 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 21 Mar 2019 14:27:32 +0000 (14:27 +0000)
2019-03-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89779
* tree.c (tree_nop_conversion): Consolidate and fix defensive
checks with respect to released SSA names now having error_mark_node
type.
* fold-const.c (operand_equal_p): Likewise.

* gcc.dg/torture/pr89779.c: New testcase.

From-SVN: r269838

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr89779.c [new file with mode: 0644]
gcc/tree.c

index 7774af8..717e2f2 100644 (file)
@@ -1,3 +1,11 @@
+2019-03-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89779
+       * tree.c (tree_nop_conversion): Consolidate and fix defensive
+       checks with respect to released SSA names now having error_mark_node
+       type.
+       * fold-const.c (operand_equal_p): Likewise.
+
 2019-03-20  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        PR target/89775
index ec28b43..86ad2cb 100644 (file)
@@ -2973,11 +2973,6 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
       || TREE_TYPE (arg1) == error_mark_node)
     return 0;
 
-  /* Similar, if either does not have a type (like a released SSA name), 
-     they aren't equal.  */
-  if (!TREE_TYPE (arg0) || !TREE_TYPE (arg1))
-    return 0;
-
   /* We cannot consider pointers to different address space equal.  */
   if (POINTER_TYPE_P (TREE_TYPE (arg0))
       && POINTER_TYPE_P (TREE_TYPE (arg1))
index 5a343b6..c8f9492 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89779
+       * gcc.dg/torture/pr89779.c: New testcase.
+
 2019-03-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/78645
diff --git a/gcc/testsuite/gcc.dg/torture/pr89779.c b/gcc/testsuite/gcc.dg/torture/pr89779.c
new file mode 100644 (file)
index 0000000..2a9d240
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+typedef int a;
+void h(a);
+void c(a *d, int b)
+{
+  int e, f, g;
+  for (; e; e++)
+    for (f = 0; f < 4; f++)
+      if (d)
+       for (g = e + 1; g; g++)
+         h(d[g]);
+}
+void i()
+{
+  a *j;
+  int k, l;
+  for (; k; k++)
+    c(j, l);
+}
index 8ea4251..ae8ff08 100644 (file)
@@ -12812,13 +12812,10 @@ tree_nop_conversion (const_tree exp)
   if (!CONVERT_EXPR_P (exp)
       && TREE_CODE (exp) != NON_LVALUE_EXPR)
     return false;
-  if (TREE_OPERAND (exp, 0) == error_mark_node)
-    return false;
 
   outer_type = TREE_TYPE (exp);
   inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
-
-  if (!inner_type)
+  if (!inner_type || inner_type == error_mark_node)
     return false;
 
   return tree_nop_conversion_p (outer_type, inner_type);