+2016-12-14 Marek Polacek <polacek@redhat.com>
+
+ PR c++/72775
+ * init.c (perform_member_init): Diagnose member initializer for
+ flexible array member.
+
2016-12-14 Nathan Sidwell <nathan@acm.org>
PR c++/78701
in that case. */
init = build_x_compound_expr_from_list (init, ELK_MEM_INIT,
tf_warning_or_error);
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == NULL_TREE
+ && init != NULL_TREE)
+ {
+ error_at (DECL_SOURCE_LOCATION (current_function_decl),
+ "member initializer for flexible array member");
+ inform (DECL_SOURCE_LOCATION (member), "%q#D initialized", member);
+ }
if (init)
finish_expr_stmt (cp_build_modify_expr (input_location, decl,
+2016-12-14 Marek Polacek <polacek@redhat.com>
+
+ PR c++/72775
+ * g++.dg/ext/flexary12.C: Adjust dg-error.
+ * g++.dg/ext/flexary20.C: New.
+ * g++.dg/ext/flexary21.C: New.
+
2016-12-14 Uros Bizjak <ubizjak@gmail.com>
PR target/59874
D ();
};
-D::D ():
+D::D (): // { dg-error "member initializer for flexible array member" }
a ("c") // { dg-error "incompatible types in assignment of .const char \\\[2\\\]. to .int \\\[\\\]." }
{ }
--- /dev/null
+// PR c++/72775
+// { dg-do compile { target c++11 } }
+// { dg-options -Wno-pedantic }
+
+struct S {
+ int i;
+ char a[] = "foo";
+ S () {} // { dg-error "member initializer for flexible array member" }
+};
+
+struct T { // { dg-error "member initializer for flexible array member" }
+ int i;
+ char a[] = "foo";
+};
+
+struct U {
+ int i;
+ char a[] = "foo";
+ U ();
+};
+
+U::U() {} // { dg-error "member initializer for flexible array member" }
+
+int
+main ()
+{
+ struct T t;
+}
+
+struct V {
+ int i;
+ struct W { // { dg-error "member initializer for flexible array member" }
+ int j;
+ char a[] = "foo";
+ } w;
+ V () {}
+};
+
+template <class T>
+struct X { // { dg-error "member initializer for flexible array member" }
+ int i;
+ T a[] = "foo";
+};
+
+void
+fn ()
+{
+ struct X<char> x;
+}
--- /dev/null
+// PR c++/72775
+// { dg-do compile { target c++11 } }
+// { dg-options -Wno-pedantic }
+
+struct S {
+ int i;
+ char a[];
+ S () : a("bob") {} // { dg-error "member initializer for flexible array member" }
+};
+
+struct T {
+ int i;
+ char a[] = "bob";
+ T () : a("bob") {} // { dg-error "member initializer for flexible array member" }
+};