From 66143cdfd1a3575ca5d92a6af788a4eb5c83f1b4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 27 Nov 2019 10:04:40 +0100 Subject: [PATCH] re PR c++/92524 (ICE in short program with constexpr and std::array) PR c++/92524 * tree.c (replace_placeholders_r): Don't walk constructor elts with RANGE_EXPR indexes. * g++.dg/cpp0x/pr92524.C: New test. From-SVN: r278759 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/tree.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/pr92524.C | 12 ++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr92524.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6cf8579377d..4cbdb4352dc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-11-27 Jakub Jelinek + + PR c++/92524 + * tree.c (replace_placeholders_r): Don't walk constructor elts with + RANGE_EXPR indexes. + 2019-11-26 Jason Merrill * pt.c (tsubst_copy_and_build) [TEMPLATE_ID_EXPR]: Remember the diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 6c39c004b01..d125d60b270 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3144,6 +3144,11 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_) tree type = TREE_TYPE (*valp); tree subob = obj; + /* Elements with RANGE_EXPR index shouldn't have any + placeholders in them. */ + if (ce->index && TREE_CODE (ce->index) == RANGE_EXPR) + continue; + if (TREE_CODE (*valp) == CONSTRUCTOR && AGGREGATE_TYPE_P (type)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index df74ba61243..ab455910c4d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-27 Jakub Jelinek + + PR c++/92524 + * g++.dg/cpp0x/pr92524.C: New test. + 2019-11-27 Richard Biener PR tree-optimization/92645 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr92524.C b/gcc/testsuite/g++.dg/cpp0x/pr92524.C new file mode 100644 index 00000000000..ffbcd8f9f3a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr92524.C @@ -0,0 +1,12 @@ +// PR c++/92524 +// { dg-do compile { target c++11 } } + +struct A { char a = '*'; }; +struct B { A b[64]; }; + +void +foo () +{ + A a; + B{a}; +} -- 2.30.2