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