summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.def2
-rw-r--r--clang/lib/Sema/SemaInit.cpp5
-rw-r--r--clang/test/CodeGen/globalinit.c1
-rw-r--r--clang/test/CodeGen/init.c1
-rw-r--r--clang/test/CodeGen/trunc-array-initializer.c3
-rw-r--r--clang/test/CodeGen/vector.c1
-rw-r--r--clang/test/Sema/array-init.c18
-rw-r--r--clang/test/Sema/vector-init.c4
-rw-r--r--clang/test/SemaCXX/dcl_init_aggr.cpp4
9 files changed, 17 insertions, 22 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.def b/clang/include/clang/Basic/DiagnosticSemaKinds.def
index 6e31de63171..8b3bd1510a5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.def
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.def
@@ -540,7 +540,7 @@ DIAG(err_variable_object_no_init, ERROR,
"variable-sized object may not be initialized")
DIAG(err_array_init_list_required, ERROR,
"initialization with '{...}' expected for array")
-DIAG(warn_excess_initializers, WARNING,
+DIAG(err_excess_initializers, ERROR,
"excess elements in array initializer")
DIAG(err_excess_initializers_in_char_array_initializer, ERROR,
"excess elements in char array initializer")
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 5d40e43039a..3440d04f07b 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -283,9 +283,10 @@ void InitListChecker::CheckExplicitInitList(InitListExpr *IList, QualType &T,
<< IList->getInit(Index)->getSourceRange();
hadError = true;
} else if (!T->isIncompleteType()) {
- // Don't warn for incomplete types, since we'll get an error elsewhere
+ // Don't complain for incomplete types, since we'll get an error
+ // elsewhere
SemaRef->Diag(IList->getInit(Index)->getLocStart(),
- diag::warn_excess_initializers)
+ diag::err_excess_initializers)
<< IList->getInit(Index)->getSourceRange();
}
}
diff --git a/clang/test/CodeGen/globalinit.c b/clang/test/CodeGen/globalinit.c
index 0f3e21a6caf..1bcb3e48f50 100644
--- a/clang/test/CodeGen/globalinit.c
+++ b/clang/test/CodeGen/globalinit.c
@@ -34,7 +34,6 @@ void booltest2() {
// Scalars in braces.
static int a = { 1 };
-static int b = { 1, 2 };
// References to enums.
enum {
diff --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c
index 9d18f0a767d..fa39ba6f5a0 100644
--- a/clang/test/CodeGen/init.c
+++ b/clang/test/CodeGen/init.c
@@ -2,7 +2,6 @@
void f1() {
// Scalars in braces.
int a = { 1 };
- int b = { 1, 2 };
}
void f2() {
diff --git a/clang/test/CodeGen/trunc-array-initializer.c b/clang/test/CodeGen/trunc-array-initializer.c
deleted file mode 100644
index f397657f8f9..00000000000
--- a/clang/test/CodeGen/trunc-array-initializer.c
+++ /dev/null
@@ -1,3 +0,0 @@
-// RUN: clang -emit-llvm %s -o %t
-
-int ary[2] = { 1, 2, 3 };
diff --git a/clang/test/CodeGen/vector.c b/clang/test/CodeGen/vector.c
index 366c9aafddc..528afdfe5e8 100644
--- a/clang/test/CodeGen/vector.c
+++ b/clang/test/CodeGen/vector.c
@@ -8,4 +8,3 @@ void f()
__v4hi x = {1,2,3};
__v4hi y = {1,2,3,4};
-__v4hi z = {1,2,3,4,5};
diff --git a/clang/test/Sema/array-init.c b/clang/test/Sema/array-init.c
index 3d2cf691274..b10d60da3fc 100644
--- a/clang/test/Sema/array-init.c
+++ b/clang/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;
diff --git a/clang/test/Sema/vector-init.c b/clang/test/Sema/vector-init.c
index 6913082228c..e2a00b1ffb4 100644
--- a/clang/test/Sema/vector-init.c
+++ b/clang/test/Sema/vector-init.c
@@ -9,7 +9,7 @@ float4 array[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
int array_sizecheck[(sizeof(array) / sizeof(float4)) == 3? 1 : -1];
float4 array2[2] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
- 9.0 }; // expected-warning {{excess elements in array initializer}}
+ 9.0 }; // expected-error {{excess elements in array initializer}}
float4 array3[2] = { {1.0, 2.0, 3.0}, 5.0, 6.0, 7.0, 8.0,
- 9.0 }; // expected-warning {{excess elements in array initializer}}
+ 9.0 }; // expected-error {{excess elements in array initializer}}
diff --git a/clang/test/SemaCXX/dcl_init_aggr.cpp b/clang/test/SemaCXX/dcl_init_aggr.cpp
index d8a41805365..41032271062 100644
--- a/clang/test/SemaCXX/dcl_init_aggr.cpp
+++ b/clang/test/SemaCXX/dcl_init_aggr.cpp
@@ -34,7 +34,7 @@ struct StaticMemberTest {
} smt = { 1, &smt.i };
// C++ [dcl.init.aggr]p6
-char cv[4] = { 'a', 's', 'd', 'f', 0 }; // expected-warning{{excess elements in array initializer}}
+char cv[4] = { 'a', 's', 'd', 'f', 0 }; // expected-error{{excess elements in array initializer}}
// C++ [dcl.init.aggr]p7
struct TooFew { int a; char* b; int c; };
@@ -103,5 +103,5 @@ union u { int a; char* b; };
u u1 = { 1 };
u u2 = u1;
u u3 = 1; // expected-error{{cannot initialize 'u3' with an rvalue of type 'int'}}
-u u4 = { 0, "asdf" }; // expected-warning{{excess elements in array initializer}}
+u u4 = { 0, "asdf" }; // expected-error{{excess elements in array initializer}}
u u5 = { "asdf" }; // expected-error{{incompatible type initializing 'char const [5]', expected 'int'}}
OpenPOWER on IntegriCloud