P0329R4: Designated Initialization
authorJakub Jelinek <jakub@redhat.com>
Mon, 20 Nov 2017 18:58:01 +0000 (19:58 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 20 Nov 2017 18:58:01 +0000 (19:58 +0100)
commitd68ddd2b35078ab61f164b268bac63767b2a8e6a
treec5234ca2dab614ccfd0a1f96421fdb36976af8bf
parent6c7a259b817ea4d1eae117a426a08fc85f943788
P0329R4: Designated Initialization

P0329R4: Designated Initialization
* parser.c (cp_parser_initializer_clause): List in comment grammar
designated-initializer-list.
(cp_parser_initializer_list): Allow .identifier = without pedwarn for
C++2A, parse .identifier { ... }.  Improve location_t argument to
pedwarn.  Add pedwarn for [cst] = designators.  Diagnose ... in
designated initializer list.  Diagnose mixing designated and
non-designated initializer clauses for C++2A.  Diagnose duplicated
identifiers in designators.
* name-lookup.h (search_anon_aggr): New declaration.
* name-lookup.c (fields_linear_search): Use search_anon_aggr.
(search_anon_aggr): New function.
* typeck2.c (process_init_constructor_record): Allow designator
to skip over some non-static data members.  Handle anonymous
aggregates.  Add diagnostics for designator order not matching
member declaration order.

* g++.dg/ext/desig2.C: Adjust comment, no sorry about designator
refering to second member.
(b): New variable and associated expected diagnostic.
* g++.dg/ext/desig4.C: For C++2A expect diagnostics.
* g++.dg/ext/desig5.C: Add dg-do dg-compile and empty dg-options.
* g++.dg/ext/desig8.C: Likewise.
* g++.dg/ext/desig9.C: New test.
* g++.dg/ext/pr27019.C: Don't expect any diagnostics.
* g++.dg/init/error2.C: Adjust expected diagnostics.
* g++.dg/cpp0x/desig1.C: Add dg-options with -pedantic, expect
warning on C99 designators.
* g++.dg/cpp2a/desig1.C: New test.
* g++.dg/cpp2a/desig2.C: New test.
* g++.dg/cpp2a/desig3.C: New test.
* g++.dg/cpp2a/desig4.C: New test.
* g++.dg/cpp2a/desig5.C: New test.
* g++.dg/cpp2a/desig6.C: New test.

From-SVN: r254964
20 files changed:
gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h
gcc/cp/parser.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/desig1.C
gcc/testsuite/g++.dg/cpp2a/desig1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/desig2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/desig3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/desig4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/desig5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/desig6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/desig2.C
gcc/testsuite/g++.dg/ext/desig4.C
gcc/testsuite/g++.dg/ext/desig5.C
gcc/testsuite/g++.dg/ext/desig8.C
gcc/testsuite/g++.dg/ext/desig9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/pr27019.C
gcc/testsuite/g++.dg/init/error2.C