Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / missing-field-initializers.c
blob1e65b2d62e1ab84c0ca01db8a7cdece6f8a1d8b8
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-field-initializers %s
3 // This was PR4808.
5 struct Foo { int a, b; };
7 struct Foo foo0 = { 1 }; // expected-warning {{missing field 'b' initializer}}
8 struct Foo foo1 = { .a = 1 }; // designator avoids MFI warning
9 struct Foo foo2 = { .b = 1 }; // designator avoids MFI warning
11 struct Foo bar0[] = {
12 { 1,2 },
13 { 1 }, // expected-warning {{missing field 'b' initializer}}
14 { 1,2 }
17 struct Foo bar1[] = {
18 1, 2,
19 1, 2,
21 }; // expected-warning {{missing field 'b' initializer}}
23 struct Foo bar2[] = { {}, {}, {} };
25 struct One { int a; int b; };
26 struct Two { float c; float d; float e; };
28 struct Three {
29 union {
30 struct One one;
31 struct Two two;
32 } both;
35 struct Three t0 = {
36 { .one = { 1, 2 } }
38 struct Three t1 = {
39 { .two = { 1.0f, 2.0f, 3.0f } }
42 struct Three data[] = {
43 { { .one = { 1, 2 } } },
44 { { .one = { 1 } } }, // expected-warning {{missing field 'b' initializer}}
45 { { .two = { 1.0f, 2.0f, 3.0f } } },
46 { { .two = { 1.0f, 2.0f } } } // expected-warning {{missing field 'e' initializer}}
49 struct { int:5; int a; int:5; int b; int:5; } noNamedImplicit[] = {
50 { 1, 2 },
51 { 1 } // expected-warning {{missing field 'b' initializer}}
54 // GH66300
55 struct S {
56 int f0;
57 int f1[];
60 // We previously would accidentally diagnose missing a field initializer for
61 // f1, now we no longer issue that warning (note, this code is still unsafe
62 // because of the buffer overrun).
63 struct S s = {1, {1, 2}};