summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/designated-initializers.c
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/Sema/designated-initializers.c')
-rw-r--r--clang/test/Sema/designated-initializers.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/clang/test/Sema/designated-initializers.c b/clang/test/Sema/designated-initializers.c
index fd4873193cf..c9a0aa7f05b 100644
--- a/clang/test/Sema/designated-initializers.c
+++ b/clang/test/Sema/designated-initializers.c
@@ -18,7 +18,8 @@ int iarray2[10] = {
};
int iarray3[10] = {
- [5 ... 12] = 2 // expected-error{{array designator index (12) exceeds array bounds (10)}}
+ [5 ... 12] = 2 // expected-error{{array designator index (12) exceeds array bounds (10)}}\
+ // expected-warning{{GNU array-range designator extension is unsupported}}
};
struct point {
@@ -44,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-warning{{GNU array-range designator extension is unsupported}}
+ [4 ... 6] = { .x = 3, .y = 4.0 } // expected-warning{{GNU array-range designator extension is unsupported}}
};
struct point array3[10] = {
@@ -116,4 +117,25 @@ struct disklabel_ops disklabel64_ops = {
// PR clang/3378
int bitwidth[] = { [(long long int)1] = 5, [(short int)2] = 2 };
int a[]= { [sizeof(int)] = 0 };
-int a2[]= { [0 ... sizeof(int)] = 0 };
+int a2[]= { [0 ... sizeof(int)] = 0 }; // expected-warning{{GNU array-range designator extension is unsupported}}
+
+// Test warnings about initializers overriding previous initializers
+struct X {
+ int a, b, c;
+};
+
+int counter = 0;
+int get8() { ++counter; return 8; }
+
+void test() {
+ struct X xs[] = {
+ [0] = (struct X){1, 2}, // expected-note{{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
+ };
+}
+
+// FIXME: we need to
+union { char c; long l; } u1 = { .l = 0xFFFF }; // expected-warning{{designated initialization of union member is broken}}
OpenPOWER on IntegriCloud