This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] add test for c++/68490 - error initializing a structure with a flexible array member
- From: Martin Sebor <msebor at gmail dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Thu, 14 Jan 2016 17:00:40 -0700
- Subject: [PATCH] add test for c++/68490 - error initializing a structure with a flexible array member
- Authentication-results: sourceware.org; auth=none
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;
+}