PR c++/80135
commit7aac6ee6ffe6aa8435365fe74b24beb3167dfde1
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Dec 2017 20:20:00 +0000 (15 20:20 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Dec 2017 20:20:00 +0000 (15 20:20 +0000)
treea45a3326c55217d9cc4a173c3032c72887d3a954
parent5b5ac2fbec718dd8dd8b5fd6fffd3242b23d5834
PR c++/80135
PR c++/81922
* typeck2.c (digest_init_r): Change nested argument type from bool to
int.  Use code instead of TREE_CODE (type) where possible.  If
nested == 2, diagnose initialization of flexible array member with
STRING_CST.  Pass nested to process_init_constructor.  Formatting fix.
(digest_init, digest_init_flags): Adjust digest_init_r caller.
(massage_init_elt): Add nested argument.  Pass 2 instead of 1 to
digest_init_r's nested argument if nested is non-zero.
(process_init_constructor_array): Add nested argument.  If nested == 2,
diagnose initialization of flexible array member with non-empty
braced enclosed list.  Pass nested to massage_init_elt.
(process_init_constructor_record, process_init_constructor_union): Add
nested argument, pass it to massage_init_elt.
(process_init_constructor): Add nested argument, pass it to
process_init_constructor_{array,record,union}.
* init.c (find_field_init): Renamed to ...
(find_flexarray_init): ... this.  Return NULL_TREE if init is
error_mark_node.  Don't look through nested CONSTRUCTORs.
(warn_placement_new_too_small): Adjust caller.

* g++.dg/warn/Wplacement-new-size-1.C (fBx1): Initialize nested
flexible array member only with {}.  Add dg-warning.
(fBx2, fBx3): Remove.
* g++.dg/warn/Wplacement-new-size-2.C (fBx1): Initialize nested
flexible array member only with {}.  Add dg-warning.
(fBx2, fBx3): Remove.
* g++.dg/warn/Wplacement-new-size-6.C: New test.
* g++.dg/ext/flexary13.C (main): Remove test for initialization
of nested flexible array member with non-empty initializer.
* g++.dg/ext/flexary25.C: New test.
* g++.dg/ext/flexary26.C: New test.
* g++.dg/ext/flexary27.C: New test.
* g++.dg/parse/pr43765.C: Expect diagnostics about initialization
of nested flexible array member with non-empty initializer.  Expect
C++2A diagnostics about mixing of designated and non-designated
initializers.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255703 138bc75d-0d04-0410-961f-82ee72b054a4
12 files changed:
gcc/cp/ChangeLog
gcc/cp/init.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/flexary13.C
gcc/testsuite/g++.dg/ext/flexary25.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/flexary26.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/flexary27.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/pr43765.C
gcc/testsuite/g++.dg/warn/Wplacement-new-size-1.C
gcc/testsuite/g++.dg/warn/Wplacement-new-size-2.C
gcc/testsuite/g++.dg/warn/Wplacement-new-size-6.C [new file with mode: 0644]