From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 0ECD03AA7C9E; Tue, 20 Apr 2021 23:30:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0ECD03AA7C9E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9403] gimplify: Gimplify value in gimplify_init_ctor_eval_range [PR98353] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: 8313557e2714f710247372caa8b473e292ebff42 X-Git-Newrev: 202240b05f28681053c64efbf1e6deb07f36e1b8 Message-Id: <20210420233058.0ECD03AA7C9E@sourceware.org> Date: Tue, 20 Apr 2021 23:30:58 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Apr 2021 23:30:58 -0000 https://gcc.gnu.org/g:202240b05f28681053c64efbf1e6deb07f36e1b8 commit r9-9403-g202240b05f28681053c64efbf1e6deb07f36e1b8 Author: Jakub Jelinek Date: Tue Dec 22 00:01:34 2020 +0100 gimplify: Gimplify value in gimplify_init_ctor_eval_range [PR98353] gimplify_init_ctor_eval_range wasn't gimplifying value, so if it wasn't a gimple val, verification at the end of gimplification would ICE (or with release checking some random pass later on would ICE or misbehave). 2020-12-21 Jakub Jelinek PR c++/98353 * gimplify.c (gimplify_init_ctor_eval_range): Gimplify value before storing it into cref. * g++.dg/opt/pr98353.C: New test. (cherry picked from commit f3113a85f098df8165624321cc85d20219fb2ada) Diff: --- gcc/gimplify.c | 6 +++++- gcc/testsuite/g++.dg/opt/pr98353.C | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8c30910d90d..ae3cd1a3828 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4497,7 +4497,11 @@ gimplify_init_ctor_eval_range (tree object, tree lower, tree upper, gimplify_init_ctor_eval (cref, CONSTRUCTOR_ELTS (value), pre_p, cleared); else - gimplify_seq_add_stmt (pre_p, gimple_build_assign (cref, value)); + { + if (gimplify_expr (&value, pre_p, NULL, is_gimple_val, fb_rvalue) + != GS_ERROR) + gimplify_seq_add_stmt (pre_p, gimple_build_assign (cref, value)); + } /* We exit the loop when the index var is equal to the upper bound. */ gimplify_seq_add_stmt (pre_p, diff --git a/gcc/testsuite/g++.dg/opt/pr98353.C b/gcc/testsuite/g++.dg/opt/pr98353.C new file mode 100644 index 00000000000..e3d0a4765b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr98353.C @@ -0,0 +1,17 @@ +// PR c++/98353 +// { dg-do compile { target c++11 } } + +template struct A {}; +template +struct B +{ + static const int n = 1; + template A ::n> foo (); + _Complex double c[2], d = 1.0; +}; + +void +bar () +{ + B().foo (); +}