]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/89403 (ICE in maybe_clone_body, at cp/optimize.c:693)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:10:10 +0000 (14:10 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:10:10 +0000 (14:10 +0200)
Backported from mainline
2019-02-20  Jakub Jelinek  <jakub@redhat.com>

PR c++/89403
* decl2.c (c_parse_final_cleanups): Move TREE_ASM_WRITTEN setting
for flag_syntax_only from here...
* semantics.c (expand_or_defer_fn_1): ... here.

* g++.dg/cpp0x/pr89403.C: New test.

From-SVN: r275119

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr89403.C [new file with mode: 0644]

index 9ffdf152cbbc9681a95c8e077d51409c6fd76367..d2d55d5f77781b3a43c4ee3296068445515072a8 100644 (file)
@@ -1,6 +1,13 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-02-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/89403
+       * decl2.c (c_parse_final_cleanups): Move TREE_ASM_WRITTEN setting
+       for flag_syntax_only from here...
+       * semantics.c (expand_or_defer_fn_1): ... here.
+
        2019-02-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/89187
index 7ad6a108224779313bda7eadbf7d5c17ef925c96..7839e6246008377ce3f6019bb438ae58665051cc 100644 (file)
@@ -4725,11 +4725,6 @@ c_parse_final_cleanups (void)
              /* Generate RTL for this function now that we know we
                 need it.  */
              expand_or_defer_fn (decl);
-             /* If we're compiling -fsyntax-only pretend that this
-                function has been written out so that we don't try to
-                expand it again.  */
-             if (flag_syntax_only)
-               TREE_ASM_WRITTEN (decl) = 1;
              reconsider = true;
            }
        }
index 0f25b6ecd39c2a48ed735594d32f52b85773d614..dd95c74d7b0aa5373ca595cc0b5c5ab37bb1fe00 100644 (file)
@@ -4298,7 +4298,12 @@ expand_or_defer_fn_1 (tree fn)
   /* There's no reason to do any of the work here if we're only doing
      semantic analysis; this code just generates RTL.  */
   if (flag_syntax_only)
-    return false;
+    {
+      /* Pretend that this function has been written out so that we don't try
+        to expand it again.  */
+      TREE_ASM_WRITTEN (fn) = 1;
+      return false;
+    }
 
   return true;
 }
index ad38331315361e4a2de301957d7d27895c832dd5..481d42a7a9b2959173ccde9f162647884061148e 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2019-02-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89403
+       * g++.dg/cpp0x/pr89403.C: New test.
+
        PR middle-end/89412
        * gcc.c-torture/compile/pr89412.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr89403.C b/gcc/testsuite/g++.dg/cpp0x/pr89403.C
new file mode 100644 (file)
index 0000000..9dc7dff
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/89403
+// { dg-do compile { target c++11 } }
+// { dg-options "-Os -fsyntax-only" }
+
+template <typename T>
+struct A : T {
+  constexpr A() : T() { }
+};
+
+template <typename T>
+struct B {
+  A<T> b;
+  constexpr B() { }
+};
+
+struct C { struct {} s; };
+constexpr B<C> b{};
+constexpr C c = b.b;