re PR middle-end/90194 (ICE in expand_debug_expr, at cfgexpand.c:5244)
authorRichard Biener <rguenther@suse.de>
Thu, 25 Apr 2019 11:15:35 +0000 (11:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 25 Apr 2019 11:15:35 +0000 (11:15 +0000)
2019-04-25  Richard Biener  <rguenther@suse.de>

PR middle-end/90194
* match.pd: Add pattern to simplify view-conversion of an
empty constructor.

* g++.dg/torture/pr90194.C: New testcase.

From-SVN: r270569

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr90194.C [new file with mode: 0644]

index d4c5b31613c51c6c2a42378fcad97ffd2959c596..2aeafe1d30c3a275ed7ab45581089da96fdbcd56 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-25  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/90194
+       * match.pd: Add pattern to simplify view-conversion of an
+       empty constructor.
+
 2019-04-24  Clement Chigot  <clement.chigot@atos.net>
 
        * config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Disable
index 0d82beab45b13cfbab4d3f24720dae3018f82c6c..039ddacfed1e849dc8e101239110f98207fbdd48 100644 (file)
@@ -2596,6 +2596,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
               && TYPE_UNSIGNED (TREE_TYPE (@1)))))
    (view_convert @1)))
 
+/* Simplify a view-converted empty constructor.  */
+(simplify
+  (view_convert CONSTRUCTOR@0)
+  (if (TREE_CODE (@0) != SSA_NAME
+       && CONSTRUCTOR_NELTS (@0) == 0)
+   { build_zero_cst (type); }))
+
 /* Re-association barriers around constants and other re-association
    barriers can be removed.  */
 (simplify
index 115c22088ef457f56fee57a7ca614c6e52363014..f1291f11c52d8db4a1c188096e9077d4fd151bc6 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-25  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/90194
+       * g++.dg/torture/pr90194.C: New testcase.
+
 2019-04-24  Marek Polacek  <polacek@redhat.com>
 
        PR c++/90236
diff --git a/gcc/testsuite/g++.dg/torture/pr90194.C b/gcc/testsuite/g++.dg/torture/pr90194.C
new file mode 100644 (file)
index 0000000..f0c3a77
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-additional-options "-g" }
+
+struct cb {
+    int yr;
+};
+
+void *
+operator new (__SIZE_TYPE__, void *nq)
+{
+  return nq;
+}
+
+void
+af (int xn)
+{
+  new (&xn) cb { };
+}