re PR c++/80135 (ICE in output_constructor_regular_field, at varasm.c:4968)
authorJakub Jelinek <jakub@redhat.com>
Fri, 15 Dec 2017 20:20:00 +0000 (21:20 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 15 Dec 2017 20:20:00 +0000 (21:20 +0100)
commita8c55cacaf8fa1e90f9e26c467a78081ae152b50
treea45a3326c55217d9cc4a173c3032c72887d3a954
parente3a661b45e8d9baf96bef773e214f4c41581bc22
re PR c++/80135 (ICE in output_constructor_regular_field, at varasm.c:4968)

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.

From-SVN: r255703
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]