aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/typeck2.c9
-rw-r--r--gcc/testsuite/g++.dg/ext/flexary37.C2
2 files changed, 10 insertions, 1 deletions
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index c01f2f8..e98fbf7 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -484,6 +484,15 @@ split_nonconstant_init_1 (tree dest, tree init, bool nested)
&& TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
|| vla_type_p (type))
{
+ if (!TYPE_DOMAIN (type)
+ && TREE_CODE (init) == CONSTRUCTOR
+ && CONSTRUCTOR_NELTS (init))
+ {
+ /* Flexible array. */
+ cp_complete_array_type (&type, init, /*default*/true);
+ dest = build1 (VIEW_CONVERT_EXPR, type, dest);
+ }
+
/* For an array, we only need/want a single cleanup region rather
than one per element. */
tree code = build_vec_init (dest, NULL_TREE, init, false, 1,
diff --git a/gcc/testsuite/g++.dg/ext/flexary37.C b/gcc/testsuite/g++.dg/ext/flexary37.C
index ceb5053..5cd48c1 100644
--- a/gcc/testsuite/g++.dg/ext/flexary37.C
+++ b/gcc/testsuite/g++.dg/ext/flexary37.C
@@ -12,4 +12,4 @@ public:
struct y { // { dg-error "unknown array size in delete" }
int a; C b[];
-} y = { 1, { { 2, 3 } } }; // { dg-error "unknown array size in delete" }
+} y = { 1, { { 2, 3 } } };