diff options
author | Chris Lattner <sabre@nondot.org> | 2010-10-10 18:16:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-10-10 18:16:20 +0000 |
commit | 16c5dea6c2d3e4cf529de9d9b37f6a40441acb2c (patch) | |
tree | 75107cd54912953a7975dc2ea367b1097b31f6ba /test/Sema/flexible-array-init.c | |
parent | 9046c224f16be3cef84f03b96a6c00a621c8383e (diff) |
fix PR8217, a silent miscompilation of invalid code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116166 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/flexible-array-init.c')
-rw-r--r-- | test/Sema/flexible-array-init.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/Sema/flexible-array-init.c b/test/Sema/flexible-array-init.c index e03881cdbc..a0f1acd071 100644 --- a/test/Sema/flexible-array-init.c +++ b/test/Sema/flexible-array-init.c @@ -7,7 +7,9 @@ struct one { 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}}; // expected-warning{{flexible array initialization is a GNU extension}} + 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 foo { @@ -56,3 +58,18 @@ struct Y { int e; struct X xs[]; // expected-warning{{'struct X' may not be used as an array element due to flexible array member}} }; + + +// PR8217 +struct PR8217a { + int i; + char v[]; +}; + +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 foo3 = { .i = 0, .v = { 'b', 'a', 'r', '\0' } }; // expected-error {{non-static initialization of a variable with flexible array member}} + struct PR8217a bar; +} + |