Debian Codegraph @

gcc/testsuite/g++.dg/ext/flexary36.C

raw
1 /* PR c++/93753 - ICE on a flexible array followed by a member in
2 an anonymous struct with an initializer
3 { dg-do compile }
4 { dg-options "-Wall -Wno-unused-variable" } */
5
6 struct {
7 int a[]; // { dg-error "flexible array member '<unnamed struct>::a' not at end of 'struct<unnamed>'" }
8 int b;
9 } ax;
10
11 struct {
12 int a[]; // { dg-error "flexible array member '<unnamed struct>::a' not at end of 'struct<unnamed>'" }
13 int b;
14 } bx = { };
15
16 struct {
17 int a[]; // { dg-error "flexible array member '<unnamed struct>::a' not at end of 'struct<unnamed>'" }
18 int b;
19 } cx = { 0 };
20
21 struct {
22 int a[]; // { dg-error "flexible array member '<unnamed struct>::a' not at end of 'struct<unnamed>'" }
23 int b;
24 } dx = { 1 };
25
26
27 union {
28 int a[];
29 int b;
30 } du = { 1 };
31
32
33 struct A {
34 int a[]; // { dg-error "flexible array member 'A::a' not at end of 'struct A'" }
35 int b;
36 } a;
37
38 struct B {
39 int a[]; // { dg-error "flexible array member 'B::a' not at end of 'struct B'" }
40 int b;
41 } b = { };
42
43 struct C {
44 int a[]; // { dg-error "flexible array member 'C::a' not at end of 'struct C'" }
45 int b;
46 } c = { 0 };
47
48 struct D {
49 int a[]; // { dg-error "flexible array member 'D::a' not at end of 'struct D'" }
50 int b;
51 } d = { 1 };
52
53
54 struct E {
55 struct {
56 int a[]; // { dg-error " not at end " }
57 int b;
58 } e = { 1 }; // { dg-error "non-static initialization of a flexible array member" }
59 };
60
61 struct G {
62 struct {
63 int a[]; // { dg-error " not at end " }
64 int b;
65 };
66 } g = { 1 }; // { dg-error "initialization of flexible array member in a nested context" }
67
68 struct H {
69 int i;
70 struct {
71 int a[]; // { dg-error " not at end " }
72 int b;
73 };
74 } h = { 1 };
75
76 namespace {
77
78 struct {
79 int a[]; // { dg-error " not at end of " }
80 int b;
81 } ax;
82
83 struct {
84 int a[]; // { dg-error " not at end " }
85 int b;
86 } bx = { };
87
88 struct {
89 int a[]; // { dg-error " not at end " }
90 int b;
91 } cx = { 0 };
92
93 struct {
94 int a[]; // { dg-error " not at end " }
95 int b;
96 } dx = { 1 };
97
98
99 struct A {
100 int a[]; // { dg-error " not at end of 'struct {anonymous}::A'" }
101 int b;
102 } a;
103
104 struct B {
105 int a[]; // { dg-error " not at end of 'struct {anonymous}::B'" }
106 int b;
107 } b = { };
108
109 struct C {
110 int a[]; // { dg-error " not at end of 'struct {anonymous}::C'" }
111 int b;
112 } c = { 0 };
113
114 struct D {
115 int a[]; // { dg-error " not at end of 'struct {anonymous}::D'" }
116 int b;
117 } d = { 1 };
118
119 }
120
121 // { dg-prune-output "unnamed type with no linkage used to declare variable" }
122 // { dg-prune-output "non-static data member initializers" }
123 // { dg-prune-output "extended initializer lists" }