diff mbox

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

Message ID 569836A8.8040202@gmail.com
State New
Headers show

Commit Message

Martin Sebor Jan. 15, 2016, midnight UTC
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

Comments

Jason Merrill Jan. 15, 2016, 8:55 p.m. UTC | #1
On 01/14/2016 07:00 PM, Martin Sebor wrote:
> 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.)

Yes, go ahead and add tests without waiting for approval.

> +// { dg-options "-Wpedantic -Wno-error=pedantic" }

You shouldn't need the -Wno-error=pedantic, though.

Jason
diff mbox

Patch

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;
+}