1 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
4 int values
[]; // expected-note 4{{initialized flexible array member 'values' is here}}
5 } x
= {5, {1, 2, 3}}; // expected-warning{{flexible array initialization is a GNU extension}}
7 struct one x2
= { 5, 1, 2, 3 }; // expected-warning{{flexible array initialization is a GNU extension}}
10 struct one x3
= {5, {1, 2, 3}}; // expected-error{{initialization of flexible array member is not allowed}}
11 struct one x3a
= { 5 };
12 struct one x3b
= { .a
= 5 };
13 struct one x3c
= { 5, {} }; // expected-warning{{use of an empty initializer is a C23 extension}} \
14 // expected-warning{{flexible array initialization is a GNU extension}} \
15 // expected-warning{{zero size arrays are an extension}}
20 int y
[]; // expected-note 8 {{initialized flexible array member 'y' is here}}
22 struct bar
{ struct foo z
; }; // expected-warning {{'z' may not be nested in a struct due to flexible array member}}
24 struct foo a
= { 1, { 2, 3, 4 } }; // expected-warning{{flexible array initialization is a GNU extension}}
25 struct bar b
= { { 1, { 2, 3, 4 } } }; // expected-error{{initialization of flexible array member is not allowed}}
26 struct bar c
= { { 1, { } } }; // // expected-warning{{flexible array initialization is a GNU extension}} \
27 // expected-warning{{use of an empty initializer is a C23 extension}} \
28 // expected-warning{{zero size arrays are an extension}}
29 struct foo d
[1] = { { 1, { 2, 3, 4 } } }; // expected-warning{{'struct foo' may not be used as an array element due to flexible array member}} \
30 // expected-error{{initialization of flexible array member is not allowed}}
32 struct foo desig_foo
= { .y
= {2, 3, 4} }; // expected-warning{{flexible array initialization is a GNU extension}}
33 struct bar desig_bar
= { .z
.y
= { } }; // expected-warning{{use of an empty initializer is a C23 extension}} \
34 // expected-warning{{zero size arrays are an extension}} \
35 // expected-warning{{flexible array initialization is a GNU extension}}
36 struct bar desig_bar2
= { .z
.y
= { 2, 3, 4} }; // expected-error{{initialization of flexible array member is not allowed}}
37 struct foo design_foo2
= { .y
= 2 }; // expected-error{{flexible array requires brace-enclosed initializer}}
45 struct point points
[]; // expected-note{{initialized flexible array member 'points' is here}}
47 struct polygon poly
= {
48 .points
[2] = { 1, 2} }; // expected-error{{designator into flexible array member subobject}}
63 struct X xs
[]; // expected-warning{{'struct X' may not be used as an array element due to flexible array member}}
70 char v
[]; // expected-note 2 {{initialized flexible array member 'v' is here}}
74 struct PR8217a foo1
= { .i
= 0, .v
= "foo" }; // expected-error {{initialization of flexible array member is not allowed}}
75 struct PR8217a foo2
= { .i
= 0 };
76 struct PR8217a foo3
= { .i
= 0, .v
= { 'b', 'a', 'r', '\0' } }; // expected-error {{initialization of flexible array member is not allowed}}
80 typedef struct PR10648
{
82 int v
[]; // expected-note {{initialized flexible array member 'v' is here}}
85 return (PR10648
){2, {3, 4}}.v
[1]; // expected-error {{initialization of flexible array member is not allowed}}
88 struct FlexWithUnnamedBitfield
{ int : 10; int x
; int y
[]; }; // expected-note {{initialized flexible array member 'y' is here}}
89 void TestFlexWithUnnamedBitfield(void) {
90 struct FlexWithUnnamedBitfield x
= {10, {3}}; // expected-error {{initialization of flexible array member is not allowed}}