]> granicus.if.org Git - clang/commitdiff
Add an assertion so that we don't accidentally build constant arrays of
authorEli Friedman <eli.friedman@gmail.com>
Fri, 29 May 2009 20:17:55 +0000 (20:17 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 29 May 2009 20:17:55 +0000 (20:17 +0000)
VLAs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72587 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
lib/Sema/SemaInit.cpp

index b230edb93d3c8eb417529d37442d34ffd9bf48c5..00eaa361a3f9122d742d92465ec8491eb3ce6480 100644 (file)
@@ -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);
index 6608e120f3c67b33f8584ad5ae571848e52c4948..fada7fe0adb164bc553d80b6b97976ee76f869d4 100644 (file)
@@ -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());