aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp7
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,