Commit a0889599 by Jason Merrill Committed by Jason Merrill

Array decomposition fix.

	* decl.c (check_initializer): Always use build_aggr_init for array
	decomposition.

From-SVN: r244639
parent b32e85fa
2017-01-19 Jason Merrill <jason@redhat.com> 2017-01-19 Jason Merrill <jason@redhat.com>
* decl.c (check_initializer): Always use build_aggr_init for array
decomposition.
PR c++/79130 - decomposition and direct-initialization PR c++/79130 - decomposition and direct-initialization
* init.c (build_aggr_init): Communicate direct-initialization to * init.c (build_aggr_init): Communicate direct-initialization to
build_vec_init. build_vec_init.
......
...@@ -6299,14 +6299,14 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups) ...@@ -6299,14 +6299,14 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
if (type == error_mark_node) if (type == error_mark_node)
return NULL_TREE; return NULL_TREE;
if ((type_build_ctor_call (type) || CLASS_TYPE_P (type) if (((type_build_ctor_call (type) || CLASS_TYPE_P (type))
|| (DECL_DECOMPOSITION_P (decl) && TREE_CODE (type) == ARRAY_TYPE)) && !(flags & LOOKUP_ALREADY_DIGESTED)
&& !(flags & LOOKUP_ALREADY_DIGESTED) && !(init && BRACE_ENCLOSED_INITIALIZER_P (init)
&& !(init && BRACE_ENCLOSED_INITIALIZER_P (init) && CP_AGGREGATE_TYPE_P (type)
&& CP_AGGREGATE_TYPE_P (type) && (CLASS_TYPE_P (type)
&& (CLASS_TYPE_P (type) || !TYPE_NEEDS_CONSTRUCTING (type)
|| !TYPE_NEEDS_CONSTRUCTING (type) || type_has_extended_temps (type))))
|| type_has_extended_temps (type)))) || (DECL_DECOMPOSITION_P (decl) && TREE_CODE (type) == ARRAY_TYPE))
{ {
init_code = build_aggr_init_full_exprs (decl, init, flags); init_code = build_aggr_init_full_exprs (decl, init, flags);
......
// { dg-options -std=c++1z }
int a[3];
struct S { int b, c, d; } s;
void
foo ()
{
auto [ b, c, d ] = a;
auto [ e, f, g ] = s;
auto [ h, i, j ] { s };
auto [ k, l, m ] { s, };
auto [ n, o, p ] { a };
auto [ q, r, t ] ( s );
auto [ u, v, w ] ( s, ); // { dg-error "expected primary-expression before '.' token" }
auto [ x, y, z ] ( a ); // { dg-error "expression list treated as compound expression in initializer" "" { target *-*-* } .-1 }
}
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