Commit 114bf260 by Jason Merrill Committed by Jason Merrill

re PR c++/59886 (C++ array init optimization results in RANGE_EXPRs in assignments)

	PR c++/59886
	PR c++/59659
	* typeck2.c (process_init_constructor_array): Don't create
	RANGE_EXPR yet.

From-SVN: r207051
parent 2cbf3dd7
2014-01-24 Jason Merrill <jason@redhat.com>
PR c++/59886
PR c++/59659
* typeck2.c (process_init_constructor_array): Don't create
RANGE_EXPR yet.
2014-01-24 Jakub Jelinek <jakub@redhat.com> 2014-01-24 Jakub Jelinek <jakub@redhat.com>
* typeck2.c (split_nonconstant_init_1): Fix num_split_elts * typeck2.c (split_nonconstant_init_1): Fix num_split_elts
......
...@@ -1201,10 +1201,10 @@ process_init_constructor_array (tree type, tree init, ...@@ -1201,10 +1201,10 @@ process_init_constructor_array (tree type, tree init,
flags |= picflag_from_initializer (ce->value); flags |= picflag_from_initializer (ce->value);
} }
/* No more initializers. If the array is unbounded, or we've initialized /* No more initializers. If the array is unbounded, we are done. Otherwise,
all the elements, we are done. Otherwise, we must add initializers we must add initializers ourselves. */
ourselves. */ if (!unbounded)
if (!unbounded && i < len) for (; i < len; ++i)
{ {
tree next; tree next;
...@@ -1232,9 +1232,7 @@ process_init_constructor_array (tree type, tree init, ...@@ -1232,9 +1232,7 @@ process_init_constructor_array (tree type, tree init,
if (next) if (next)
{ {
flags |= picflag_from_initializer (next); flags |= picflag_from_initializer (next);
tree index = build2 (RANGE_EXPR, sizetype, size_int (i), CONSTRUCTOR_APPEND_ELT (v, size_int (i), next);
size_int (len - 1));
CONSTRUCTOR_APPEND_ELT (v, index, next);
} }
} }
......
// PR c++/59886
struct A { A (); ~A (); };
struct B { A b[4]; };
struct C { B c[5]; };
const C e = {};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment