[cfe-commits] r51086 - /cfe/trunk/lib/Sema/SemaType.cpp

Eli Friedman eli.friedman at gmail.com
Tue May 13 17:40:18 PDT 2008


Author: efriedma
Date: Tue May 13 19:40:18 2008
New Revision: 51086

URL: http://llvm.org/viewvc/llvm-project?rev=51086&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Sema/SemaType.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue May 13 19:40:18 2008
@@ -339,10 +339,12 @@
         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





More information about the cfe-commits mailing list