re PR middle-end/89790 (ICE segfault in operand_equal_p() at fold-const.c:3000 with...
authorRichard Biener <rguenther@suse.de>
Mon, 25 Mar 2019 10:05:15 +0000 (10:05 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 25 Mar 2019 10:05:15 +0000 (10:05 +0000)
2019-03-25  Richard Biener  <rguenther@suse.de>

PR middle-end/89790
* fold-const.c (operand_equal_p): Revert last change with
updated comment.

* g++.dg/pr89790.C: New testcase.

From-SVN: r269907

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

index 8ce3d7cd337b0e82a95a64c2f9c4456e01b66158..fd07440fe42e07a160c94a783db9fd434ba52d0b 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-25  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89790
+       * fold-const.c (operand_equal_p): Revert last change with
+       updated comment.
+
 2019-03-24  Segher Boessenkool  <segher@kernel.crashing.org>
 
        * config/rs6000/rs6000.c (rs6000_legitimize_tls_address): Add REG_EQUAL
index 86ad2cb8487f3f2fc720380ea47a382d59ab5e6f..c2884a67519342e23ce8e2d6ee0741fea225edf5 100644 (file)
@@ -2973,6 +2973,11 @@ 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 template id),
+     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 a4560af1d173fcacd5a7cb4a04d1f027e4d6961c..74b1483a0cb4cd4c2e0783fed138e72c42e6581d 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-25  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89790
+       * g++.dg/pr89790.C: New testcase.
+
 2019-03-24  Uroš Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/pr82281.c: Compile only for ia32 effective target.
diff --git a/gcc/testsuite/g++.dg/pr89790.C b/gcc/testsuite/g++.dg/pr89790.C
new file mode 100644 (file)
index 0000000..c4d9766
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-options "-Wduplicated-cond" }
+
+template <typename>
+class a
+{
+  typedef a b;
+  template <typename> void c();
+};
+template <typename d> template <typename>
+void a<d>::c()
+{
+  int f;
+  b g;
+  if (g == 0)
+    ;
+  else if (f)
+    {
+    }
+}