]> granicus.if.org Git - clang/commitdiff
An array of VLAs is a VLA. Shouldn't make any significant difference at
authorEli Friedman <eli.friedman@gmail.com>
Wed, 14 May 2008 00:40:18 +0000 (00:40 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 14 May 2008 00:40:18 +0000 (00:40 +0000)
the moment, but it what you'd expect in the AST from reading the
standard, and it should make VLA codegen a bit more strightforward.

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

lib/Sema/SemaType.cpp

index 85ff96111a5bb2a22633a2d7579b97df51226243..9bb211bd30293c5d62b3e67e9dc12e8bf1a4b5fa 100644 (file)
@@ -339,10 +339,12 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
         ATI.NumElts = ArraySize = 0;
       }
       llvm::APSInt ConstVal(32);
-      // If no expression was provided, we consider it an incomplete array.
       if (!ArraySize) {
         T = Context.getIncompleteArrayType(T, ASM, ATI.TypeQuals);
-      } else if (!ArraySize->isIntegerConstantExpr(ConstVal, Context)) {
+      } else if (!ArraySize->isIntegerConstantExpr(ConstVal, Context) ||
+                 !T->isConstantSizeType()) {
+        // Per C99, a variable array is an array with either a non-constant
+        // size or an element type that has a non-constant-size
         T = Context.getVariableArrayType(T, ArraySize, ASM, ATI.TypeQuals);
       } else {
         // C99 6.7.5.2p1: If the expression is a constant expression, it shall