re PR c++/89403 (ICE in maybe_clone_body, at cp/optimize.c:693)
authorJakub Jelinek <jakub@redhat.com>
Thu, 21 Feb 2019 00:09:47 +0000 (01:09 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 21 Feb 2019 00:09:47 +0000 (01:09 +0100)
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: r269059

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 58df2b5953cbc464ae8ba6cbde0653d034bd370d..5367aae5cc1bcf62f2deaf8e28476720c41ed401 100644 (file)
@@ -1,5 +1,10 @@
 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.
+
        PR c++/89405
        * decl.c (maybe_commonize_var): When clearing TREE_PUBLIC and
        DECL_COMMON, set DECL_INTERFACE_KNOWN.
index 72c52e39e00d1e4cbeb1ec07095747fa2793b93a..18db79eb4f9ace9a50196fe489dd7fcc8a878d65 100644 (file)
@@ -4965,11 +4965,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 3ecd192bced7b8667f2092dca4b6471aa62895e8..da814bdd655769b10755471929329d7a64e72aa0 100644 (file)
@@ -4352,7 +4352,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 d8d6ef94287bb942ceef461ff960dbde4f3e5934..2068a41ed7f4748da58eff7ebd2a6672df5ee56b 100644 (file)
@@ -1,5 +1,8 @@
 2019-02-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89403
+       * g++.dg/cpp0x/pr89403.C: New test.
+
        PR c++/89405
        * g++.dg/cpp1z/inline-var5.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;