+2017-02-21 Marek Polacek <polacek@redhat.com>
+
+ PR c++/79535
+ * cp-tree.h (maybe_reject_flexarray_init): Declare.
+ * init.c (maybe_reject_flexarray_init): No longer static.
+ Add check for current_function_decl.
+ * parser.c (cp_parser_late_parse_one_default_arg): Reject
+ a default mem-initializer for a flexible array.
+
2017-02-21 Jakub Jelinek <jakub@redhat.com>
Paolo Carlini <paolo.carlini@oracle.com>
extern tree decl_really_constant_value (tree);
extern int diagnose_uninitialized_cst_or_ref_member (tree, bool, bool);
extern tree build_vtbl_address (tree);
+extern bool maybe_reject_flexarray_init (tree, tree);
/* in lex.c */
extern void cxx_dup_lang_specific_decl (tree);
/* Diagnose the flexible array MEMBER if its INITializer is non-null
and return true if so. Otherwise return false. */
-static bool
+bool
maybe_reject_flexarray_init (tree member, tree init)
{
tree type = TREE_TYPE (member);
initializer list. */
location_t loc;
if (DECL_INITIAL (member) == init
+ || !current_function_decl
|| DECL_DEFAULTED_FN (current_function_decl))
loc = DECL_SOURCE_LOCATION (member);
else
if (TREE_CODE (decl) == PARM_DECL)
parsed_arg = check_default_argument (parmtype, parsed_arg,
tf_warning_or_error);
+ else if (maybe_reject_flexarray_init (decl, parsed_arg))
+ parsed_arg = error_mark_node;
else
parsed_arg = digest_nsdmi_init (decl, parsed_arg);
}
+2017-02-21 Marek Polacek <polacek@redhat.com>
+
+ PR c++/79535
+ * g++.dg/ext/flexary23.C: New test.
+
2017-02-21 Jakub Jelinek <jakub@redhat.com>
PR c++/79654
--- /dev/null
+// PR c++/79535 - ICE with NSDMI and array
+// { dg-do compile { target c++14 } }
+// { dg-options -Wno-pedantic }
+
+struct A
+{
+ int b = 1;
+ int c = 2;
+ int x[] = { c, 3 }; // { dg-error "initializer for flexible array member" }
+};
+A a = { 4, 5 };