diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-01-30 22:26:29 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-01-30 22:26:29 +0000 |
commit | b574e5630d66629ccc8f2432e60b59ae42f1f363 (patch) | |
tree | 57abe70449a27cb6189ca5e4fbc3c35ceb60c1f4 /test/Sema/array-init.c | |
parent | 930d8b5ecc074cca01ecd9a522a55f55f3b72396 (diff) |
Upgrade the "excess elements in array initializer" warning to an
error, since both C99 and C++ consider it an error. For reference, GCC
makes this a warning while G++ makes it an error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63435 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/array-init.c')
-rw-r--r-- | test/Sema/array-init.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c index 3d2cf69127..b10d60da3f 100644 --- a/test/Sema/array-init.c +++ b/test/Sema/array-init.c @@ -20,7 +20,7 @@ void func() { int x3[x] = { 1, 2 }; // expected-error{{variable-sized object may not be initialized}} - int x4 = { 1, 2 }; // expected-warning{{braces around scalar initializer}} expected-warning{{excess elements in array initializer}} + int x4 = { 1, 2 }; // expected-warning{{braces around scalar initializer}} expected-error{{excess elements in array initializer}} int y[4][3] = { { 1, 3, 5 }, @@ -37,7 +37,7 @@ void func() { { 2, 4, 6 }, { 3, 5, 7 }, { 4, 6, 8 }, - { 5 }, // expected-warning{{excess elements in array initializer}} + { 5 }, // expected-error{{excess elements in array initializer}} }; struct threeElements { @@ -53,17 +53,17 @@ void func() { void test() { int y1[3] = { - { 1, 2, 3 } // expected-warning{{braces around scalar initializer}} expected-warning{{excess elements in array initializer}} + { 1, 2, 3 } // expected-warning{{braces around scalar initializer}} expected-error{{excess elements in array initializer}} }; int y3[4][3] = { { 1, 3, 5 }, { 2, 4, 6 }, { 3, 5, 7 }, { 4, 6, 8 }, - { }, // expected-warning{{use of GNU empty initializer extension}} expected-warning{{excess elements in array initializer}} + { }, // expected-warning{{use of GNU empty initializer extension}} expected-error{{excess elements in array initializer}} }; int y4[4][3] = { - { 1, 3, 5, 2 }, // expected-warning{{excess elements in array initializer}} + { 1, 3, 5, 2 }, // expected-error{{excess elements in array initializer}} { 4, 6 }, { 3, 5, 7 }, { 4, 6, 8 }, @@ -178,7 +178,7 @@ float r2[] = {{8}}; //expected-warning{{braces around scalar initializer}} char r3[][5] = {1,2,3,4,5,6}; int r3_sizecheck[(sizeof(r3) / sizeof(char[5])) == 2? 1 : -1]; char r3_2[sizeof r3 == 10 ? 1 : -1]; -float r4[1][2] = {1,{2},3,4}; //expected-warning{{braces around scalar initializer}} expected-warning{{excess elements in array initializer}} +float r4[1][2] = {1,{2},3,4}; //expected-warning{{braces around scalar initializer}} expected-error{{excess elements in array initializer}} char r5[][5] = {"aa", "bbb", "ccccc"}; char r6[sizeof r5 == 15 ? 1 : -1]; const char r7[] = "zxcv"; @@ -203,12 +203,12 @@ int bar (void) { struct s3 {void (*a)(void);} t5 = {autoStructTest}; // FIXME: GCC extension; flexible array init. Once this is implemented, the warning should be removed. // Note that clang objc implementation depends on this extension. -struct {int a; int b[];} t6 = {1, {1, 2, 3}}; //expected-warning{{excess elements in array initializer}} +struct {int a; int b[];} t6 = {1, {1, 2, 3}}; //expected-error{{excess elements in array initializer}} union {char a; int b;} t7[] = {1, 2, 3}; int t8[sizeof t7 == (3*sizeof(int)) ? 1 : -1]; struct bittest{int : 31, a, :21, :12, b;}; -struct bittest bittestvar = {1, 2, 3, 4}; //expected-warning{{excess elements in array initializer}} +struct bittest bittestvar = {1, 2, 3, 4}; //expected-error{{excess elements in array initializer}} // Not completely sure what should happen here... int u1 = {}; //expected-warning{{use of GNU empty initializer extension}} expected-error{{scalar initializer cannot be empty}} @@ -243,7 +243,7 @@ struct soft_segment_descriptor gdt_segs[] = { }; static void sppp_ipv6cp_up(); -const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct extension}} expected-warning{{excess elements in array initializer}} +const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct extension}} expected-error{{excess elements in array initializer}} struct _Matrix { union { float m[4][4]; }; }; //expected-warning{{anonymous unions are a GNU extension in C}} typedef struct _Matrix Matrix; |