From: Eli Friedman Date: Wed, 14 May 2008 00:40:18 +0000 (+0000) Subject: An array of VLAs is a VLA. Shouldn't make any significant difference at X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37148aabe7d153ce682b5715a820a11c0bbfcd59;p=clang An array of VLAs is a VLA. Shouldn't make any significant difference at 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 --- diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 85ff96111a..9bb211bd30 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -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