blob: 0ceded07f2e3fffa87f396f08545b8027fe88429 [file] [log] [blame]
John McCalle40b58e2010-03-11 19:32:38 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-field-initializers %s
2
3struct Foo { int a, b; };
4
5struct Foo foo0 = { 1 }; // expected-warning {{missing field 'b' initializer}}
6struct Foo foo1 = { .a = 1 }; // designator avoids MFI warning
7struct Foo foo2 = { .b = 1 }; // designator avoids MFI warning
8
9struct Foo bar0[] = {
10 { 1,2 },
11 { 1 }, // expected-warning {{missing field 'b' initializer}}
12 { 1,2 }
13};
14
15struct Foo bar1[] = {
16 1, 2,
17 1, 2,
18 1
19}; // expected-warning {{missing field 'b' initializer}}
20
21struct One { int a; int b; };
22struct Two { float c; float d; float e; };
23
24struct Three {
25 union {
26 struct One one;
27 struct Two two;
28 } both;
29};
30
31struct Three t0 = {
32 { .one = { 1, 2 } }
33};
34struct Three t1 = {
35 { .two = { 1.0f, 2.0f, 3.0f } }
36};
37
38struct Three data[] = {
39 { { .one = { 1, 2 } } },
40 { { .one = { 1 } } }, // expected-warning {{missing field 'b' initializer}}
41 { { .two = { 1.0f, 2.0f, 3.0f } } },
42 { { .two = { 1.0f, 2.0f } } } // expected-warning {{missing field 'e' initializer}}
43};
44
45struct { int:5; int a; int:5; int b; int:5 } noNamedImplicit[] = {
46 { 1, 2 },
47 { 1 } // expected-warning {{missing field 'b' initializer}}
48};