[cfe-commits] r72587 - in /cfe/trunk/lib: AST/ASTContext.cpp Sema/SemaInit.cpp

Eli Friedman eli.friedman at gmail.com
Fri May 29 13:17:57 PDT 2009


Author: efriedma
Date: Fri May 29 15:17:55 2009
New Revision: 72587

URL: http://llvm.org/viewvc/llvm-project?rev=72587&view=rev
Log:
Add an assertion so that we don't accidentally build constant arrays of 
VLAs.


Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=72587&r1=72586&r2=72587&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri May 29 15:17:55 2009
@@ -1063,6 +1063,9 @@
                                           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);

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=72587&r1=72586&r2=72587&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri May 29 15:17:55 2009
@@ -909,7 +909,7 @@
     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());





More information about the cfe-commits mailing list