+2018-03-27 Paolo Carlini <paolo.carlini@oracle.com>
+ Jason Merrill <jason@redhat.com>
+
+ PR c++/84632
+ * init.c (build_aggr_init): When initializing from array,
+ reject anything but CONSTRUCTORs and TARGET_EXPRs.
+ (build_vec_init): Handle separately ARRAY_TYPEs.
+
2018-03-26 Jason Merrill <jason@redhat.com>
PR c++/85062 - ICE with alignas in wrong place.
}
else
{
- /* An array may not be initialized use the parenthesized
- initialization form -- unless the initializer is "()". */
- if (init && TREE_CODE (init) == TREE_LIST)
- {
- if (complain & tf_error)
- error ("bad array initializer");
- return error_mark_node;
- }
/* Must arrange to initialize each element of EXP
from elements of INIT. */
if (cv_qualified_p (type))
from_array = (itype && same_type_p (TREE_TYPE (init),
TREE_TYPE (exp)));
- if (init && !from_array
- && !BRACE_ENCLOSED_INITIALIZER_P (init))
+ if (init && !BRACE_ENCLOSED_INITIALIZER_P (init)
+ && (!from_array
+ || (TREE_CODE (init) != CONSTRUCTOR
+ /* Can happen, eg, handling the compound-literals
+ extension (ext/complit12.C). */
+ && TREE_CODE (init) != TARGET_EXPR)))
{
if (complain & tf_error)
- permerror (init_loc, "array must be initialized "
- "with a brace-enclosed initializer");
- else
- return error_mark_node;
+ error_at (init_loc, "array must be initialized "
+ "with a brace-enclosed initializer");
+ return error_mark_node;
}
}
else
from = NULL_TREE;
- if (from_array == 2)
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ elt_init = build_vec_init (to, NULL_TREE, from, /*val_init*/false,
+ from_array, complain);
+ else if (from_array == 2)
elt_init = cp_build_modify_expr (input_location, to, NOP_EXPR,
from, complain);
else if (type_build_ctor_call (type))