This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] add test for c++/68490 - error initializing a structure with a flexible array member


Among the bugs fixed by the flexible array patch (r231665) was
c++/68490.  I forgot to include a test for this bug in the commit
so I'm adding it via the attached patch.

(Please let me know if adding new passing tests is considered
trivial and I don't need to request approval for such things.)

Thanks
Martin
2016-01-14  Martin Sebor  <msebor@redhat.com>

	PR c++/68490
	* g++.dg/ext/flexary10.C: New test.

Index: testsuite/g++.dg/ext/flexary10.C
===================================================================
--- testsuite/g++.dg/ext/flexary10.C	(revision 0)
+++ testsuite/g++.dg/ext/flexary10.C	(working copy)
@@ -0,0 +1,18 @@
+// PR c++/68490 - error initializing a structure with a flexible array member
+// { dg-do compile }
+// { dg-options "-Wpedantic -Wno-error=pedantic" }
+
+struct A {
+  int n;
+  int a [];
+};
+
+struct A foo (void)
+{
+  // Verify the initializer below is accepted for compatibility with gcc
+  // (in C mode).
+  static struct A
+    a = { 2, { 1, 0 } };   // { dg-warning "initialization of a flexible array member" }
+
+  return a;
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]