aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaType.cpp3
-rw-r--r--test/SemaCXX/c99-variable-length-array.cpp14
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index ea2b2e6812..35efa6113b 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -711,7 +711,8 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
if (!getLangOptions().C99) {
if (T->isVariableArrayType()) {
// Prohibit the use of non-POD types in VLAs.
- if (!Context.getBaseElementType(T)->isPODType()) {
+ if (!T->isDependentType() &&
+ !Context.getBaseElementType(T)->isPODType()) {
Diag(Loc, diag::err_vla_non_pod)
<< Context.getBaseElementType(T);
return QualType();
diff --git a/test/SemaCXX/c99-variable-length-array.cpp b/test/SemaCXX/c99-variable-length-array.cpp
index 8267701880..7dc912a0d5 100644
--- a/test/SemaCXX/c99-variable-length-array.cpp
+++ b/test/SemaCXX/c99-variable-length-array.cpp
@@ -100,3 +100,17 @@ namespace rdar8020206 {
template void f<int>(int); // expected-note{{instantiation of}}
}
+
+namespace rdar8021385 {
+ typedef int my_int;
+ struct A { typedef int my_int; };
+ template<typename T>
+ struct B {
+ typedef typename T::my_int my_int;
+ void f0() {
+ int M = 4;
+ my_int a[M]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ }
+ };
+ B<A> a;
+}