John McCall | 80639de | 2010-03-11 19:32:38 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-field-initializers %s |
| 2 | |
John McCall | d7358a3 | 2010-03-11 19:33:57 +0000 | [diff] [blame] | 3 | // This was PR4808. |
| 4 | |
John McCall | 80639de | 2010-03-11 19:32:38 +0000 | [diff] [blame] | 5 | struct Foo { int a, b; }; |
| 6 | |
| 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 |
| 10 | |
| 11 | struct Foo bar0[] = { |
| 12 | { 1,2 }, |
| 13 | { 1 }, // expected-warning {{missing field 'b' initializer}} |
| 14 | { 1,2 } |
| 15 | }; |
| 16 | |
| 17 | struct Foo bar1[] = { |
| 18 | 1, 2, |
| 19 | 1, 2, |
| 20 | 1 |
| 21 | }; // expected-warning {{missing field 'b' initializer}} |
| 22 | |
| 23 | struct One { int a; int b; }; |
| 24 | struct Two { float c; float d; float e; }; |
| 25 | |
| 26 | struct Three { |
| 27 | union { |
| 28 | struct One one; |
| 29 | struct Two two; |
| 30 | } both; |
| 31 | }; |
| 32 | |
| 33 | struct Three t0 = { |
| 34 | { .one = { 1, 2 } } |
| 35 | }; |
| 36 | struct Three t1 = { |
| 37 | { .two = { 1.0f, 2.0f, 3.0f } } |
| 38 | }; |
| 39 | |
| 40 | struct 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 | |
| 47 | struct { int:5; int a; int:5; int b; int:5 } noNamedImplicit[] = { |
| 48 | { 1, 2 }, |
| 49 | { 1 } // expected-warning {{missing field 'b' initializer}} |
| 50 | }; |