Split out incomplete arrays from VariableArrayType into
IncompleteArrayType. This should make code dealing with both incomplete
and variable length arrays much more readable, plus it allows properly
making the distinction between isVariableArrayType() and
isVariablyModifiedType(). The patch is a little big, but it's
strightforward. so I don't think there should be any issues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47165 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index 5ba2586..58d7019 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -231,9 +231,11 @@
}
llvm::APSInt ConstVal(32);
// If no expression was provided, we consider it a VLA.
- if (!ArraySize || !ArraySize->isIntegerConstantExpr(ConstVal, Context))
+ if (!ArraySize) {
+ T = Context.getIncompleteArrayType(T, ASM, ATI.TypeQuals);
+ } else if (!ArraySize->isIntegerConstantExpr(ConstVal, Context)) {
T = Context.getVariableArrayType(T, ArraySize, ASM, ATI.TypeQuals);
- else {
+ } else {
// C99 6.7.5.2p1: If the expression is a constant expression, it shall
// have a value greater than zero.
if (ConstVal.isSigned()) {