}
}
+/* Return true if it's OK to initialize an array TYPE from INIT. Mere mortals
+ can't copy arrays, but the compiler can do so with a VEC_INIT_EXPR in
+ certain cases. */
+
+static bool
+can_init_array_with_p (tree type, tree init)
+{
+ if (!init)
+ /* Value-init, OK. */
+ return true;
+ if (!same_type_ignoring_top_level_qualifiers_p (type, TREE_TYPE (init)))
+ return false;
+ /* We're called from synthesize_method, and we're processing the
+ mem-initializers of a constructor. */
+ if (DECL_DEFAULTED_FN (current_function_decl))
+ return true;
+ /* As an extension, we allow copying from a compound literal. */
+ if (TREE_CODE (init) == TARGET_EXPR)
+ {
+ init = TARGET_EXPR_INITIAL (init);
+ if (TREE_CODE (init) == CONSTRUCTOR)
+ return CONSTRUCTOR_C99_COMPOUND_LITERAL (init);
+ }
+
+ return false;
+}
+
/* Initialize MEMBER, a FIELD_DECL, with INIT, a TREE_LIST of
arguments. If TREE_LIST is void_type_node, an empty initializer
list was given; if NULL_TREE no initializer was given. UNINITIALIZED
{
if (TREE_CODE (type) == ARRAY_TYPE)
{
- if (init == NULL_TREE
- || same_type_ignoring_top_level_qualifiers_p (type,
- TREE_TYPE (init)))
+ if (can_init_array_with_p (type, init))
{
if (TYPE_DOMAIN (type) && TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
{