extwarn about VLAs in C89 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41545 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index 5582c5a..04264a3 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -165,6 +165,7 @@
break;
case DeclaratorChunk::Array: {
const DeclaratorChunk::ArrayTypeInfo &ATI = DeclType.Arr;
+ Expr *ArraySize = static_cast<Expr*>(ATI.NumElts);
ArrayType::ArraySizeModifier ASM;
if (ATI.isStar)
ASM = ArrayType::Star;
@@ -201,8 +202,13 @@
D.setInvalidType(true);
}
}
- T = Context.getArrayType(T, ASM, ATI.TypeQuals,
- static_cast<Expr *>(ATI.NumElts));
+ T = Context.getArrayType(T, ASM, ATI.TypeQuals, ArraySize);
+
+ // If this is not C99, extwarn about VLA's and C99 array size modifiers.
+ if (!getLangOptions().C99 &&
+ (ASM != ArrayType::Normal ||
+ (ArraySize && !ArraySize->isIntegerConstantExpr(Context))))
+ Diag(D.getIdentifierLoc(), diag::ext_vla);
break;
}
case DeclaratorChunk::Function: