summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGen/flexible-array-init.c8
-rw-r--r--clang/test/Sema/array-init.c4
-rw-r--r--clang/test/Sema/flexible-array-init.c14
3 files changed, 17 insertions, 9 deletions
diff --git a/clang/test/CodeGen/flexible-array-init.c b/clang/test/CodeGen/flexible-array-init.c
new file mode 100644
index 00000000000..0e2fcc69d11
--- /dev/null
+++ b/clang/test/CodeGen/flexible-array-init.c
@@ -0,0 +1,8 @@
+// RUN: clang -triple i386-unknown-unknown -emit-llvm -o - %s | grep 7 | count 1 &&
+// RUN: clang -triple i386-unknown-unknown -emit-llvm -o - %s | grep 11 | count 1 &&
+// RUN: clang -triple i386-unknown-unknown -emit-llvm -o - %s | grep 13 | count 1 &&
+// RUN: clang -triple i386-unknown-unknown -emit-llvm -o - %s | grep 15 | count 1
+
+struct { int x; int y[]; } a = { 1, 7, 11 };
+
+struct { int x; int y[]; } b = { 1, { 13, 15 } };
diff --git a/clang/test/Sema/array-init.c b/clang/test/Sema/array-init.c
index 4ee86181afe..0c1bbc04709 100644
--- a/clang/test/Sema/array-init.c
+++ b/clang/test/Sema/array-init.c
@@ -201,8 +201,8 @@ int bar (void) {
return z.z;
}
struct s3 {void (*a)(void);} t5 = {autoStructTest};
-// Note that clang objc implementation depends on this extension.
-struct {int a; int b[];} t6 = {1, {1, 2, 3}};
+struct {int a; int b[];} t6 = {1, {1, 2, 3}}; // expected-warning{{flexible array initialization is a GNU extension}} \
+// expected-note{{initialized flexible array member 'b' is here}}
union {char a; int b;} t7[] = {1, 2, 3};
int t8[sizeof t7 == (3*sizeof(int)) ? 1 : -1];
diff --git a/clang/test/Sema/flexible-array-init.c b/clang/test/Sema/flexible-array-init.c
index fff5fee2afc..2b8f40fa5b0 100644
--- a/clang/test/Sema/flexible-array-init.c
+++ b/clang/test/Sema/flexible-array-init.c
@@ -1,24 +1,24 @@
// RUN: clang -fsyntax-only -pedantic -verify %s
struct one {
int a;
- int values[];
-} x = {5, {1, 2, 3}};
+ int values[]; // expected-note 3{{initialized flexible array member 'values' is here}}
+} x = {5, {1, 2, 3}}; // expected-warning{{flexible array initialization is a GNU extension}}
-struct one x2 = { 5, 1, 2, 3 }; // expected-warning{{excess elements in struct initializer}}
+struct one x2 = { 5, 1, 2, 3 }; // expected-warning{{flexible array initialization is a GNU extension}}
void test() {
- struct one x3 = {5, {1, 2, 3}};
+ struct one x3 = {5, {1, 2, 3}}; // expected-warning{{flexible array initialization is a GNU extension}}
}
struct foo {
int x;
- int y[]; // expected-note 4 {{initialized flexible array member 'y' is here}}
+ int y[]; // expected-note 6 {{initialized flexible array member 'y' is here}}
};
struct bar { struct foo z; }; // expected-warning {{'z' may not be nested in a struct due to flexible array member}}
-struct foo a = { 1, { 2, 3, 4 } }; // Valid.
+struct foo a = { 1, { 2, 3, 4 } }; // expected-warning{{flexible array initialization is a GNU extension}}
struct bar b = { { 1, { 2, 3, 4 } } }; // expected-error{{non-empty initialization of flexible array member inside subobject}}
-struct bar c = { { 1, { } } }; // Valid. \
+struct bar c = { { 1, { } } }; // // expected-warning{{flexible array initialization is a GNU extension}} \
// expected-warning{{use of GNU empty initializer extension}} \
// expected-warning{{zero size arrays are an extension}}
struct foo d[1] = { { 1, { 2, 3, 4 } } }; // expected-warning{{'struct foo' may not be used as an array element due to flexible array member}} \
OpenPOWER on IntegriCloud