From 587cbdfd95f4b0aaccc14b31f5debe85d5daf7ed Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 29 May 2009 20:17:55 +0000 Subject: [PATCH] Add an assertion so that we don't accidentally build constant arrays of VLAs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72587 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 3 +++ lib/Sema/SemaInit.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index b230edb93d..00eaa361a3 100644 --- a/lib/AST/ASTContext.cpp +++ b/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/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 6608e120f3..fada7fe0ad 100644 --- a/lib/Sema/SemaInit.cpp +++ b/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()); -- 2.40.0