Polish yesterday's Array/ConstantArray/VariableArray rewrite, removing a couple FIXME's.
Refactored Array/VariableArray, moving SizeModifier/IndexTypeQuals back up to Array. These
attributes are not specific to VLA's. Most of them are specific to array parameter types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41616 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index 3bc0e76..d1d62a6 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -202,8 +202,13 @@
D.setInvalidType(true);
}
}
- T = Context.getArrayType(T, ASM, ATI.TypeQuals, ArraySize);
-
+ llvm::APSInt ConstVal(32);
+ // If no expression was provided, we consider it a VLA.
+ if (!ArraySize || !ArraySize->isIntegerConstantExpr(ConstVal, Context))
+ T = Context.getVariableArrayType(T, ArraySize, ASM, ATI.TypeQuals);
+ else
+ T = Context.getConstantArrayType(T, ConstVal, ASM, ATI.TypeQuals);
+
// If this is not C99, extwarn about VLA's and C99 array size modifiers.
if (!getLangOptions().C99 &&
(ASM != ArrayType::Normal ||