diff options
author | Jason Merrill <jason@redhat.com> | 2018-04-05 13:17:11 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-04-05 13:17:11 -0400 |
commit | da0c07b20f79549eb8b1f1fe11ac5639f9083e49 (patch) | |
tree | 1427046bb225b1f64a4fcb6f4d4173e44fb2c9b6 | |
parent | 61f84e25f6cbfb182bfaa4334d44f3c865c4c0b7 (diff) | |
download | gcc-da0c07b20f79549eb8b1f1fe11ac5639f9083e49.zip gcc-da0c07b20f79549eb8b1f1fe11ac5639f9083e49.tar.gz gcc-da0c07b20f79549eb8b1f1fe11ac5639f9083e49.tar.bz2 |
PR c++/83808 - ICE with VLA initialization.
* typeck2.c (process_init_constructor_array): Don't require a VLA
initializer to have VLA type.
From-SVN: r259138
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/vla19.C | 16 |
3 files changed, 27 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4065440..7fef0c8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-05 Jason Merrill <jason@redhat.com> + + PR c++/83808 - ICE with VLA initialization. + * typeck2.c (process_init_constructor_array): Don't require a VLA + initializer to have VLA type. + 2018-04-05 Paolo Carlini <paolo.carlini@oracle.com> PR c++/80956 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3bdeae1..e5f9a68 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1319,9 +1319,11 @@ process_init_constructor_array (tree type, tree init, int nested, ce->value = massage_init_elt (TREE_TYPE (type), ce->value, nested, complain); - if (ce->value != error_mark_node) - gcc_assert (same_type_ignoring_top_level_qualifiers_p - (TREE_TYPE (type), TREE_TYPE (ce->value))); + gcc_checking_assert + (ce->value == error_mark_node + || (same_type_ignoring_top_level_qualifiers_p + (strip_array_types (TREE_TYPE (type)), + strip_array_types (TREE_TYPE (ce->value))))); flags |= picflag_from_initializer (ce->value); } diff --git a/gcc/testsuite/g++.dg/ext/vla19.C b/gcc/testsuite/g++.dg/ext/vla19.C new file mode 100644 index 0000000..287a0d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vla19.C @@ -0,0 +1,16 @@ +// PR c++/83808 +// { dg-additional-options "-Wno-vla" } + +struct R { int r; }; +void baz (char *, char *, char *, char *); + +void +foo () +{ + const R a = { 12 }; + char b[1][a.r] = { { "12345678901" } }; + char c[a.r] = { "12345678901" }; + char d[1][a.r] = { { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '\0' } }; + char e[a.r] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '\0' }; + baz (b[0], c, d[0], e); +} |