summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2009-02-02 22:32:08 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2009-02-02 22:32:08 +0000
commit026bcde14b17595782b2bcb95138eee1d077c3ee (patch)
treebd85aab2a4c3020aead3653d4338cfb7f289b62e /clang/lib/Sema/SemaDecl.cpp
parenta02e45ca19ad664d8d99f7c2647a3d49b855b2d9 (diff)
downloadbcm5719-llvm-026bcde14b17595782b2bcb95138eee1d077c3ee.tar.gz
bcm5719-llvm-026bcde14b17595782b2bcb95138eee1d077c3ee.zip
fix TryToFixInvalidVariablyModifiedType to reject negative array sizes
llvm-svn: 63557
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d03879e907e..21fe6e1ce49 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3114,9 +3114,10 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T,
assert(EvalResult.Val.isInt() && "Size expressions must be integers!");
llvm::APSInt &Res = EvalResult.Val.getInt();
-
- return Context.getConstantArrayType(VLATy->getElementType(),
- Res, ArrayType::Normal, 0);
+ if (Res >= llvm::APSInt(Res.getBitWidth(), Res.isUnsigned()))
+ return Context.getConstantArrayType(VLATy->getElementType(),
+ Res, ArrayType::Normal, 0);
+ return QualType();
}
bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
OpenPOWER on IntegriCloud