c++: Fix ({ ... }) array mem-initializer.
authorJason Merrill <jason@redhat.com>
Tue, 4 Feb 2020 19:21:59 +0000 (14:21 -0500)
committerJason Merrill <jason@redhat.com>
Tue, 4 Feb 2020 19:49:19 +0000 (14:49 -0500)
commita1c9c9ff06ab15e697d5bac6ea6e5da2df840cf5
treeaf34dc70a827bcd8d370e55e2834c5d90c5f8446
parentc422cec54a5495f6f42b80f35a11c5508fe8eec3
c++: Fix ({ ... }) array mem-initializer.

Here, we were going down the wrong path in perform_member_init because of
the incorrect parens around the mem-initializer for the array.  And then
cxx_eval_vec_init_1 didn't know what to do with a CONSTRUCTOR as the
initializer.  The latter issue was a straightforward fix, but I also wanted
to fix us silently accepting the parens, which led to factoring out handling
of TREE_LIST and flexarrays.  The latter led to adjusting the expected
behavior on flexary29.C: we should complain about the initializer, but not
complain about a missing initializer.

As I commented on PR 92812, in this process I noticed that we weren't
handling C++20 parenthesized aggregate initialization as a mem-initializer.
So my TREE_LIST handling includes a commented out section that should
probably be part of a future fix for that issue; with it uncommented we
continue to crash on the testcase in C++20 mode, but should instead complain
about the braced-init-list not being a valid initializer for an A.

PR c++/86917
* init.c (perform_member_init): Simplify.
* constexpr.c (cx_check_missing_mem_inits): Allow uninitialized
flexarray.
(cxx_eval_vec_init_1): Handle CONSTRUCTOR.
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/init.c
gcc/testsuite/g++.dg/cpp0x/constexpr-array23.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/desig2.C
gcc/testsuite/g++.dg/cpp0x/desig3.C
gcc/testsuite/g++.dg/cpp0x/desig4.C
gcc/testsuite/g++.dg/ext/array1.C
gcc/testsuite/g++.dg/ext/flexary29.C
gcc/testsuite/g++.dg/init/array28.C