c++: anon union designated init [PR105925]
commitd610ae121e8ecd738de4dc01e6ac11ecf7c2327e
authorJason Merrill <jason@redhat.com>
Thu, 23 Jun 2022 20:04:02 +0000 (23 16:04 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 23 Jun 2022 21:16:17 +0000 (23 17:16 -0400)
treeefedfa834e6a179ccb96ea80f0537aa2870bc97e
parentb00b95198e6720eb23a2618870d67800f6180fdd
c++: anon union designated init [PR105925]

This testcase was failing because CONSTRUCTOR_IS_DESIGNATED_INIT wasn't
getting set on the introduced CONSTRUCTOR for the anonymous union, and
build_aggr_conv uses that flag to decide whether to pay attention to the
indexes of the CONSTRUCTOR.  So set the flag when we see a designator rather
than relying on copying it from another CONSTRUCTOR.

This avoids some redundant errors on desig4.C because we stop setting
CONSTRUCTOR_IS_DESIGNATED_INIT on _Complex CONSTRUCTORs where it's
nonsense.

PR c++/105925

gcc/cp/ChangeLog:

* decl.cc (reshape_init_array_1): Set
CONSTRUCTOR_IS_DESIGNATED_INIT here.
(reshape_init_class): And here.
(reshape_init): Not here.

gcc/testsuite/ChangeLog:

* g++.dg/ext/desig4.C: Remove extra errors.
* g++.dg/cpp2a/desig26.C: New test.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/cpp2a/desig26.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/desig4.C