re PR c++/93046 (ICE in cp_gimplify_init_expr)
authorJakub Jelinek <jakub@redhat.com>
Sun, 5 Jan 2020 00:49:14 +0000 (01:49 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 5 Jan 2020 00:49:14 +0000 (01:49 +0100)
PR c++/93046
* cp-gimplify.c (cp_gimplify_init_expr): Don't look through
TARGET_EXPR if it has been gimplified already.

* g++.dg/ext/cond4.C: New test.

From-SVN: r279884

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/cond4.C [new file with mode: 0644]

index 421048b79d0fced18629b1e57ec7cf46abd710d1..a1fb787e55526d28f2645fe4bfddf99e8636220f 100644 (file)
@@ -1,3 +1,9 @@
+2010-01-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/93046
+       * cp-gimplify.c (cp_gimplify_init_expr): Don't look through
+       TARGET_EXPR if it has been gimplified already.
+
 2020-01-03  Jason Merrill  <jason@redhat.com>
 
        PR c++/93033 - incorrect tree node sharing with array init.
index eb552767f61bb7ed535ef86c84d7d0d4e945d216..1d2a77d2c0ad330f203768a3a3389d57dfaa4921 100644 (file)
@@ -523,7 +523,7 @@ cp_gimplify_init_expr (tree *expr_p, gimple_seq *pre_p)
      think that such code never uses the TARGET_EXPR as an initializer.  If
      I'm wrong, we'll abort because the temp won't have any RTL.  In that
      case, I guess we'll need to replace references somehow.  */
-  if (TREE_CODE (from) == TARGET_EXPR)
+  if (TREE_CODE (from) == TARGET_EXPR && TARGET_EXPR_INITIAL (from))
     from = TARGET_EXPR_INITIAL (from);
 
   /* If we might need to clean up a partially constructed object, break down
index 18f14799d7d10ab3d7d4d860ea1ddce06a3537ba..4581c9f6c2777c7acac2121e5717cf7a7ddf25f3 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/93046
+       * g++.dg/ext/cond4.C: New test.
+
 2020-01-04  Tobias Burnus  <tobias@codesourcery.com>
 
        PR fortran/91640
diff --git a/gcc/testsuite/g++.dg/ext/cond4.C b/gcc/testsuite/g++.dg/ext/cond4.C
new file mode 100644 (file)
index 0000000..d2853f4
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/93046
+// { dg-do compile }
+// { dg-options "" }
+
+struct S {
+  S (int);
+  operator bool ();
+};
+
+S
+foo ()
+{
+  return S (1) ? : S (2);
+}