summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-01-05 00:13:19 +0000
committerJohn McCall <rjmccall@apple.com>2012-01-05 00:13:19 +0000
commita59dc2f8f0afedb980a301359e9e621f6e604853 (patch)
treee5bd1b225f0a66a7b996545613185e0f39f7749b /clang/lib/Sema
parentfcc54a3b91c9b429e0384238fbe42f73fec757ca (diff)
downloadbcm5719-llvm-a59dc2f8f0afedb980a301359e9e621f6e604853.tar.gz
bcm5719-llvm-a59dc2f8f0afedb980a301359e9e621f6e604853.zip
The value of a const weak variable is not an integer constant.
llvm-svn: 147575
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
-rw-r--r--clang/lib/Sema/SemaInit.cpp15
2 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 43c9af58bc9..f82026f89f9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6045,7 +6045,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
// If the type changed, it means we had an incomplete type that was
// completed by the initializer. For example:
// int ary[] = { 1, 3, 5 };
- // "ary" transitions from a VariableArrayType to a ConstantArrayType.
+ // "ary" transitions from an IncompleteArrayType to a ConstantArrayType.
if (!VDecl->isInvalidDecl() && (DclT != SavT)) {
VDecl->setType(DclT);
Init->setType(DclT.getNonReferenceType());
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 7a28a448239..bcb624be899 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -2427,6 +2427,7 @@ bool InitializationSequence::isAmbiguous() const {
case FK_ArrayTypeMismatch:
case FK_NonConstantArrayInit:
case FK_ListInitializationFailed:
+ case FK_VariableLengthArrayHasInitializer:
case FK_PlaceholderType:
return false;
@@ -4060,6 +4061,11 @@ InitializationSequence::InitializationSequence(Sema &S,
// - Otherwise, if the destination type is an array, the program is
// ill-formed.
if (const ArrayType *DestAT = Context.getAsArrayType(DestType)) {
+ if (Initializer && isa<VariableArrayType>(DestAT)) {
+ SetFailed(FK_VariableLengthArrayHasInitializer);
+ return;
+ }
+
if (Initializer && IsStringInit(Initializer, DestAT, Context)) {
TryStringLiteralInitialization(S, Entity, Kind, Initializer, *this);
return;
@@ -5277,6 +5283,11 @@ bool InitializationSequence::Diagnose(Sema &S,
<< Args[0]->getSourceRange();
break;
+ case FK_VariableLengthArrayHasInitializer:
+ S.Diag(Kind.getLocation(), diag::err_variable_object_no_init)
+ << Args[0]->getSourceRange();
+ break;
+
case FK_AddressOfOverloadFailed: {
DeclAccessPair Found;
S.ResolveAddressOfOverloadedFunction(Args[0],
@@ -5659,6 +5670,10 @@ void InitializationSequence::dump(raw_ostream &OS) const {
OS << "list initialization checker failure";
break;
+ case FK_VariableLengthArrayHasInitializer:
+ OS << "variable length array has an initializer";
+ break;
+
case FK_PlaceholderType:
OS << "initializer expression isn't contextually valid";
break;
OpenPOWER on IntegriCloud