diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-05-29 20:17:55 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-05-29 20:17:55 +0000 |
commit | be7e42b27fdc67d34806e42b586458e8cba34b04 (patch) | |
tree | 7505be753d6857c93046eb95084cf55e79c7474c /clang | |
parent | 15de5918908e1008ea570385208cf16949b98d3e (diff) | |
download | bcm5719-llvm-be7e42b27fdc67d34806e42b586458e8cba34b04.tar.gz bcm5719-llvm-be7e42b27fdc67d34806e42b586458e8cba34b04.zip |
Add an assertion so that we don't accidentally build constant arrays of
VLAs.
llvm-svn: 72587
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b230edb93d3..00eaa361a3f 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1063,6 +1063,9 @@ QualType ASTContext::getConstantArrayType(QualType EltTy, const llvm::APInt &ArySizeIn, ArrayType::ArraySizeModifier ASM, unsigned EltTypeQuals) { + assert((EltTy->isDependentType() || EltTy->isConstantSizeType()) && + "Constant array of VLAs is illegal!"); + // Convert the array size into a canonical width matching the pointer size for // the target. llvm::APInt ArySize(ArySizeIn); diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 6608e120f3c..fada7fe0adb 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -909,7 +909,7 @@ void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType, if (!maxElementsKnown && elementIndex > maxElements) maxElements = elementIndex; } - if (DeclType->isIncompleteArrayType()) { + if (!hadError && DeclType->isIncompleteArrayType()) { // If this is an incomplete array type, the actual type needs to // be calculated here. llvm::APSInt Zero(maxElements.getBitWidth(), maxElements.isUnsigned()); |