diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-02-22 18:29:51 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-02-22 18:29:51 +0000 |
commit | cd9ec3b4fb3d042f89aa5b572de7df3ef9ee4a80 (patch) | |
tree | 2d199d905bd174e50578c1ec1ec807bdb320c30e /test/Sema/array-init.c | |
parent | 769ce3e93ad35bd9ac28e4d8b8f035ae4fd9a5b5 (diff) |
Implement the GNU C extension which permits the initialization of an
array from a constant array compound literal. Fixes PR9261.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/array-init.c')
-rw-r--r-- | test/Sema/array-init.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c index 0ee22c0f19..345ab6981b 100644 --- a/test/Sema/array-init.c +++ b/test/Sema/array-init.c @@ -264,3 +264,17 @@ void test_matrix() { } char badchararray[1] = { badchararray[0], "asdf" }; // expected-warning {{excess elements in array initializer}} expected-error {{initializer element is not a compile-time constant}} + +// Test the GNU extension for initializing an array from an array +// compound literal. PR9261. +typedef int int5[5]; +int a1[5] = (int[]){1, 2, 3, 4, 5}; // expected-warning{{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}} +int a2[5] = (int[5]){1, 2, 3, 4, 5}; // expected-warning{{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}} +int a3[] = ((int[]){1, 2, 3, 4, 5}); // expected-warning{{initialization of an array of type 'int []' from a compound literal of type 'int [5]' is a GNU extension}} +int a4[] = (int[5]){1, 2, 3, 4, 5}; // expected-warning{{initialization of an array of type 'int []' from a compound literal of type 'int [5]' is a GNU extension}} +int a5[] = (int5){1, 2, 3, 4, 5}; // expected-warning{{initialization of an array of type 'int []' from a compound literal of type 'int5' (aka 'int [5]') is a GNU extension}} + +int a6[5] = (int[]){1, 2, 3}; // expected-error{{cannot initialize array of type 'int [5]' with array of type 'int [3]'}} + +int nonconst_value(); +int a7[5] = (int[5]){ 1, 2, 3, 4, nonconst_value() }; // expected-error{{initializer element is not a compile-time constant}} |