aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-09-20 16:06:26 -0400
committerJason Merrill <jason@redhat.com>2022-09-30 23:45:08 -0400
commitdd9c8f644f0f1ac2000108ac369b991664946304 (patch)
tree2800429f8d45544895f10aac2254578d2f84ee1f
parentf8cb417d6a4e2912d15a6d8bdffd1548cc649b49 (diff)
downloadgcc-dd9c8f644f0f1ac2000108ac369b991664946304.zip
gcc-dd9c8f644f0f1ac2000108ac369b991664946304.tar.gz
gcc-dd9c8f644f0f1ac2000108ac369b991664946304.tar.bz2
c++: loop through array CONSTRUCTOR
I noticed that we were ignoring all the special rules for when to use a simple INIT_EXPR for array initialization from a CONSTRUCTOR, because split_nonconstant_init_1 was also passing 1 to the from_array parameter. Arguably that's the real bug, but I think we can be flexible. The test that I noticed this with no longer fails without it. gcc/cp/ChangeLog: * init.cc (build_vec_init): Clear from_array for CONSTRUCTOR initializer.
-rw-r--r--gcc/cp/init.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index a85c303..bf46578 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -4394,6 +4394,10 @@ build_vec_init (tree base, tree maxindex, tree init,
}
}
+ /* from_array doesn't apply to initialization from CONSTRUCTOR. */
+ if (init && TREE_CODE (init) == CONSTRUCTOR)
+ from_array = 0;
+
/* If we have a braced-init-list or string constant, make sure that the array
is big enough for all the initializers. */
bool length_check = (init
@@ -4493,7 +4497,7 @@ build_vec_init (tree base, tree maxindex, tree init,
/* If initializing one array from another, initialize element by
element. We rely upon the below calls to do the argument
checking. Evaluate the initializer before entering the try block. */
- if (from_array && init && TREE_CODE (init) != CONSTRUCTOR)
+ if (from_array)
{
if (lvalue_kind (init) & clk_rvalueref)
xvalue = true;