aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp6
1 files changed, 4 insertions, 2 deletions
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