From e843f1890b6ee39a82a05ff4a7e8a9afa11fe4f5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 21 Feb 2019 01:09:47 +0100 Subject: [PATCH] re PR c++/89403 (ICE in maybe_clone_body, at cp/optimize.c:693) 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 | 5 +++++ gcc/cp/decl2.c | 5 ----- gcc/cp/semantics.c | 7 ++++++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/pr89403.C | 18 ++++++++++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr89403.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 58df2b5953c..5367aae5cc1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2019-02-20 Jakub Jelinek + 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. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 72c52e39e00..18db79eb4f9 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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; } } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3ecd192bced..da814bdd655 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d8d6ef94287..2068a41ed7f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-02-20 Jakub Jelinek + 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 index 00000000000..9dc7dff8bcc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr89403.C @@ -0,0 +1,18 @@ +// PR c++/89403 +// { dg-do compile { target c++11 } } +// { dg-options "-Os -fsyntax-only" } + +template +struct A : T { + constexpr A() : T() { } +}; + +template +struct B { + A b; + constexpr B() { } +}; + +struct C { struct {} s; }; +constexpr B b{}; +constexpr C c = b.b; -- 2.30.2