diff options
Diffstat (limited to 'test/Sema/designated-initializers.c')
-rw-r--r-- | test/Sema/designated-initializers.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/test/Sema/designated-initializers.c b/test/Sema/designated-initializers.c index 6630da67c5bd..a4582deb171e 100644 --- a/test/Sema/designated-initializers.c +++ b/test/Sema/designated-initializers.c @@ -45,8 +45,8 @@ struct point array[10] = { struct point array2[10] = { [10].x = 2.0, // expected-error{{array designator index (10) exceeds array bounds (10)}} - [4 ... 5].y = 2.0, - [4 ... 6] = { .x = 3, .y = 4.0 } + [4 ... 5].y = 2.0, // expected-note 2 {{previous initialization is here}} + [4 ... 6] = { .x = 3, .y = 4.0 } // expected-warning 2 {{subobject initialization overrides initialization of other fields within its enclosing subobject}} }; struct point array3[10] = { @@ -129,11 +129,11 @@ int get8() { ++counter; return 8; } void test() { struct X xs[] = { - [0] = (struct X){1, 2}, // expected-note{{previous initialization is here}} + [0] = (struct X){1, 2}, // expected-note 2 {{previous initialization is here}} [0].c = 3, // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}} (struct X) {4, 5, 6}, // expected-note{{previous initialization is here}} [1].b = get8(), // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}} - [0].b = 8 + [0].b = 8 // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}} }; } @@ -332,12 +332,22 @@ struct overwrite_string_struct { int M; } overwrite_string[] = { { { "foo" }, 1 }, // expected-note {{previous initialization is here}} - [0].L[2] = 'x' // expected-warning{{initializer overrides prior initialization of this subobject}} + [0].L[2] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}} }; struct overwrite_string_struct2 { char L[6]; int M; } overwrite_string2[] = { - { { "foo" }, 1 }, - [0].L[4] = 'x' // no-warning + { { "foo" }, 1 }, // expected-note{{previous initialization is here}} + [0].L[4] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}} }; +struct overwrite_string_struct +overwrite_string3[] = { + "foo", 1, // expected-note{{previous initialization is here}} + [0].L[4] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}} +}; +struct overwrite_string_struct +overwrite_string4[] = { + { { 'f', 'o', 'o' }, 1 }, + [0].L[4] = 'x' // no-warning +}; |