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 | 1dfa6e15cba39f27a438d63837435596e58af1c1 (patch) | |
tree | 738525588a18ffa898ffaa39fd6edd8b3e11693d /lib/Sema/SemaDecl.cpp | |
parent | 2b1e0039a1937e3df59b5c99bcf4746360db3441 (diff) |
fix TryToFixInvalidVariablyModifiedType to reject negative array sizes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d03879e907..21fe6e1ce4 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/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, |