c++: designated init of char array by string constant [PR55227]
There are two underlying bugs in the designated initialization of char array
fields by string literals that cause:
(1) Rejection of valid cases with:
(a) brace-enclosed string literal initializer (of any valid size), or
(b) unbraced string literal shorter than the target char array field.
(2) Acceptance of invalid cases with designators appearing within the braces
of a braced string literal, in which case the bogus 'designator' was
being entirely ignored and the string literal treated as a positional
initializer.
The fixes above allow to address a FIXME in cp_complete_array_type:
/* FIXME: this code is duplicated from reshape_init.
Probably we should just call reshape_init here? */
I believe that this was obstructed by the designator bugs (see comment here
https://patchwork.ozlabs.org/project/gcc/list/?series=199783)
PR c++/55227
gcc/cp/ChangeLog:
* decl.cc (reshape_init_r): Only call has_designator_check when
first_initializer_p or for the inner constructor element.
(cp_complete_array_type): Call reshape_init on braced-init-list.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/desig21.C: New test.