diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2009-02-02 22:32:08 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2009-02-02 22:32:08 +0000 |
commit | 026bcde14b17595782b2bcb95138eee1d077c3ee (patch) | |
tree | bd85aab2a4c3020aead3653d4338cfb7f289b62e /clang/lib/Sema/SemaDecl.cpp | |
parent | a02e45ca19ad664d8d99f7c2647a3d49b855b2d9 (diff) | |
download | bcm5719-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.cpp | 7 |
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, |