c++: CWG 2359, wrong copy-init with designated init [PR91319]
commit4a92205ef1da044eaf9490e61787836a3abe7d6c
authorMarek Polacek <polacek@redhat.com>
Fri, 25 Aug 2023 15:47:54 +0000 (25 11:47 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 30 Aug 2023 18:24:46 +0000 (30 14:24 -0400)
treeafd2304f639ba3240748dc28e1eef8336dfb43a1
parentc121afc3b6c96a1f229ba0c4a4de6bd4b6be9a53
c++: CWG 2359, wrong copy-init with designated init [PR91319]

This CWG clarifies that designated initializer support direct-initialization.
Just be careful what Note 2 in [dcl.init.aggr]/4.2 says: "If the
initialization is by designated-initializer-clause, its form determines
whether copy-initialization or direct-initialization is performed."  Hence
this patch sets CONSTRUCTOR_IS_DIRECT_INIT only when we are dealing with
".x{}", but not ".x = {}".

PR c++/91319

gcc/cp/ChangeLog:

* parser.cc (cp_parser_initializer_list): Set CONSTRUCTOR_IS_DIRECT_INIT
when the designated initializer is of the .x{} form.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/desig30.C: New test.
gcc/cp/parser.cc
gcc/testsuite/g++.dg/cpp2a/desig30.C [new file with mode: 0644]