===================================================================
@@ -564,7 +564,7 @@ get_nsdmi (tree member, bool in_ctor)
tf_warning_or_error, member, /*function_p=*/false,
/*integral_constant_expression_p=*/false));
- init = digest_nsdmi_init (member, init);
+ init = digest_nsdmi_init (TREE_TYPE (member), init);
}
else
{
===================================================================
@@ -24278,7 +24283,7 @@ cp_parser_late_parse_one_default_arg (cp_parser *p
parsed_arg = check_default_argument (parmtype, parsed_arg,
tf_warning_or_error);
else
- parsed_arg = digest_nsdmi_init (decl, parsed_arg);
+ parsed_arg = digest_nsdmi_init (TREE_TYPE (decl), parsed_arg);
}
/* If the token stream has not been completely used up, then
===================================================================
@@ -1159,16 +1159,18 @@ digest_init_flags (tree type, tree init, int flags
return digest_init_r (type, init, false, flags, tf_warning_or_error);
}
-/* Process the initializer INIT for an NSDMI DECL (a FIELD_DECL). */
+/* Process the initializer INIT for an NSDMI decl of type TYPE. */
+
tree
-digest_nsdmi_init (tree decl, tree init)
+digest_nsdmi_init (tree type, tree init)
{
- gcc_assert (TREE_CODE (decl) == FIELD_DECL);
-
int flags = LOOKUP_IMPLICIT;
if (DIRECT_LIST_INIT_P (init))
flags = LOOKUP_NORMAL;
- init = digest_init_flags (TREE_TYPE (decl), init, flags);
+ if (BRACE_ENCLOSED_INITIALIZER_P (init)
+ && CP_AGGREGATE_TYPE_P (type))
+ init = reshape_init (type, init, tf_warning_or_error);
+ init = digest_init_flags (type, init, flags);
if (TREE_CODE (init) == TARGET_EXPR)
/* This represents the whole initialization. */
TARGET_EXPR_DIRECT_INIT_P (init) = true;
===================================================================
@@ -0,0 +1,10 @@
+// PR c++/65815
+// { dg-do compile { target c++11 } }
+
+struct array {
+ int data [2];
+};
+
+struct X {
+ array a = { 1, 2 };
+};