summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-10-15 23:53:28 +0000
committerDouglas Gregor <dgregor@apple.com>2010-10-15 23:53:28 +0000
commit1f81ced14cc29a8bb5e52ce11d7ebe204c8cc138 (patch)
tree21b73fde2bcec42285f04ba7c823f08d0253e873 /clang/test
parentad5f98a9b224876465ea16c097d6ec889491351c (diff)
downloadbcm5719-llvm-1f81ced14cc29a8bb5e52ce11d7ebe204c8cc138.tar.gz
bcm5719-llvm-1f81ced14cc29a8bb5e52ce11d7ebe204c8cc138.zip
Allow list-initialization of a local variable of class type with a
flexible array member, so long as the flexibility array member is either not initialized or is initialized with an empty initializer list. Fixes <rdar://problem/8540437>. llvm-svn: 116647
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Sema/flexible-array-init.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/test/Sema/flexible-array-init.c b/clang/test/Sema/flexible-array-init.c
index a0f1acd0715..12f5d4f5d60 100644
--- a/clang/test/Sema/flexible-array-init.c
+++ b/clang/test/Sema/flexible-array-init.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
struct one {
int a;
- int values[]; // expected-note 3{{initialized flexible array member 'values' is here}}
+ int values[]; // expected-note 4{{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{{flexible array initialization is a GNU extension}}
@@ -10,6 +10,11 @@ void test() {
struct one x3 = {5, {1, 2, 3}}; // \
// expected-warning{{flexible array initialization is a GNU extension}} \
// expected-error {{non-static initialization of a variable with flexible array member}}
+ struct one x3a = { 5 };
+ struct one x3b = { .a = 5 };
+ struct one x3c = { 5, {} }; // expected-warning{{use of GNU empty initializer extension}} \
+ // expected-warning{{flexible array initialization is a GNU extension}} \
+ // expected-warning{{zero size arrays are an extension}}
}
struct foo {
@@ -68,7 +73,7 @@ struct PR8217a {
void PR8217() {
struct PR8217a foo1 = { .i = 0, .v = "foo" }; // expected-error {{non-static initialization of a variable with flexible array member}}
- struct PR8217a foo2 = { .i = 0 }; // expected-error {{non-static initialization of a variable with flexible array member}}
+ struct PR8217a foo2 = { .i = 0 };
struct PR8217a foo3 = { .i = 0, .v = { 'b', 'a', 'r', '\0' } }; // expected-error {{non-static initialization of a variable with flexible array member}}
struct PR8217a bar;
}
OpenPOWER on IntegriCloud