blob: 9ef6eb3bc00a98f68a2fa369faddc564c39ab58c [file] [log] [blame]
Douglas Gregoreeb15d42009-02-04 22:46:25 +00001// RUN: clang -fsyntax-only -verify %s
2struct one {
3 int a;
4 int values[];
5} x = {5, {1, 2, 3}};
6
7struct one x2 = { 5, 1, 2, 3 }; // expected-error{{excess elements in struct initializer}}
8
9void test() {
10 struct one x3 = {5, {1, 2, 3}};
11}
12
13struct foo {
14 int x;
15 int y[]; // expected-note{{initialized flexible array member 'y' is here}}
16};
17struct bar { struct foo z; };
18
19struct foo a = { 1, { 2, 3, 4 } }; // Valid.
20struct bar b = { { 1, { 2, 3, 4 } } }; // expected-error{{non-empty initialization of flexible array member inside subobject}}
21struct bar c = { { 1, { } } }; // Valid.
22struct foo d[1] = { { 1, { 2, 3, 4 } } }; // expected-error{{'struct foo' may not be used as an array element due to flexible array member}}
23
24struct foo desig_foo = { .y = {2, 3, 4} };
25struct bar desig_bar = { .z.y = { } };
26struct bar desig_bar2 = { .z.y = { 2, 3, 4} }; // expected-error{{non-empty initialization of flexible array member inside subobject}}
27struct foo design_foo2 = { .y = 2 }; // expected-error{{flexible array requires brace-enclosed initializer}}
28
29struct point {
30 int x, y;
31};
32
33struct polygon {
34 int numpoints;
35 struct point points[]; // expected-note{{initialized flexible array member 'points' is here}}
36};
37struct polygon poly = {
38 .points[2] = { 1, 2} }; // expected-error{{designator into flexible array member subobject}}