* doc/extend.texi (Loop-Specific Pragmas): Document pragma GCC unroll.
[official-gcc.git] / gcc / testsuite / g++.dg / ext / flexary12.C
blob61726f63f2846ac0383ca74fe8717656193b1292
1 // PR c++/69290 - [6 Regression] g++ ICE on invalid initialization
2 //     of a flexible array member
3 // { dg-do compile }
5 // Suppress pedantic errors about initialization of a flexible array member.
6 // { dg-options "-Wno-pedantic" }
8 struct A {
9   int a [];  // { dg-error "flexible array member .A::a. in an otherwise empty .struct A." }
12 void f1 ()
14   // This is the meat of the test from c++/69290:
15   struct A a
16     = { "c" };   // { dg-error "invalid conversion from .const char\\*. to .int." }
18   (void)&a;
22 // Exercise other forms of invalid initialization besides the one in the bug.
23 struct B {
24   int n;
25   int a [];
28 void f2 ()
30   struct B b1
31     = { 0, "c" };   // { dg-error "invalid conversion from .const char\\*. to .int." }
33   (void)&b1;
35   const char s[] = "c";
36   struct B b2
37     = { 0, s };   // { dg-error "invalid conversion from .const char\\*. to .int." }
39   (void)&b2;
42 struct D {
43   int a [];  // { dg-error "flexible array member .D::a. in an otherwise empty .struct D." }
44   D ();
47 D::D ():    // { dg-error "initializer for flexible array member" }
48   a ("c")   // the initializer also has an invalid type but emitting
49             // just the error above is sufficient
50 { }
53 template <class T>
54 struct C {
55   T a [];  // { dg-error "flexible array member" }
58 void f3 ()
60   struct C<double> cd
61     = { "c" };   // { dg-error "cannot convert .const char\\*. to .double." }
63   (void)&cd;