From: Jakub Jelinek Date: Fri, 30 Aug 2019 12:10:10 +0000 (+0200) Subject: backport: re PR c++/89403 (ICE in maybe_clone_body, at cp/optimize.c:693) X-Git-Tag: releases/gcc-7.5.0~244 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f40240efc5a4b4b3184f76ab117f9854386ba2a9;p=thirdparty%2Fgcc.git backport: re PR c++/89403 (ICE in maybe_clone_body, at cp/optimize.c:693) Backported from mainline 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. * g++.dg/cpp0x/pr89403.C: New test. From-SVN: r275119 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9ffdf152cbbc..d2d55d5f7778 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,13 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 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. + 2019-02-05 Jakub Jelinek PR c++/89187 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 7ad6a1082247..7839e6246008 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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; } } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0f25b6ecd39c..dd95c74d7b0a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ad3833131536..481d42a7a9b2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,9 @@ Backported from mainline 2019-02-20 Jakub Jelinek + 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 index 000000000000..9dc7dff8bcc7 --- /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;