+2020-02-10 Jason Merrill <jason@redhat.com>
+
+ PR c++/93618
+ * tree.c (array_of_unknown_bound_p): New.
+ * init.c (perform_member_init): Do nothing for flexible arrays.
+
2020-02-09 Jakub Jelinek <jakub@redhat.com>
PR c++/93633
extern tree bind_template_template_parm (tree, tree);
extern tree array_type_nelts_total (tree);
extern tree array_type_nelts_top (tree);
+extern bool array_of_unknown_bound_p (const_tree);
extern tree break_out_target_exprs (tree, bool = false);
extern tree build_ctor_subob_ref (tree, tree, tree);
extern tree replace_placeholders (tree, tree, bool * = NULL);
member);
}
- if (maybe_reject_flexarray_init (member, init))
- return;
+ if (array_of_unknown_bound_p (type))
+ {
+ maybe_reject_flexarray_init (member, init);
+ return;
+ }
if (init && TREE_CODE (init) == TREE_LIST
&& (DIRECT_LIST_INIT_P (TREE_VALUE (init))
return build_cplus_array_type (elt, build_index_type (size_int (n - 1)));
}
+/* True iff T is an array of unknown bound. */
+
+bool
+array_of_unknown_bound_p (const_tree t)
+{
+ return (TREE_CODE (t) == ARRAY_TYPE
+ && !TYPE_DOMAIN (t));
+}
+
/* True iff T is an N3639 array of runtime bound (VLA). These were approved
for C++14 but then removed. This should only be used for N3639
specifically; code wondering more generally if something is a VLA should use
--- /dev/null
+// PR c++/93618
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+template <typename T>
+struct C {
+ ~C () = default;
+ T *p = nullptr;
+};
+
+class A {
+ struct B {
+ int c;
+ C<B*> d[];
+ };
+ void foo (int f) { B s; s.c = f; }
+ B e;
+};