summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-02-08 02:30:49 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-02-08 02:30:49 +0000
commit04d6d2f2af6de891688ee107b672aa2fb612204a (patch)
tree557a22ec9a2cb61ba71e80d9739474ecee3762e1
parent18066822a8ffb2f338ef83210444f228b0b1156a (diff)
downloadbcm5719-llvm-04d6d2f2af6de891688ee107b672aa2fb612204a.tar.gz
bcm5719-llvm-04d6d2f2af6de891688ee107b672aa2fb612204a.zip
PR18581: Attempt to complete the type in a VLA declaration before checking
whether it's POD. llvm-svn: 201018
-rw-r--r--clang/lib/Sema/SemaType.cpp1
-rw-r--r--clang/test/SemaCXX/vla.cpp14
2 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index c2ff2238d5f..f9f6cee994e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1590,6 +1590,7 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
// Prohibit the use of non-POD types in VLAs.
QualType BaseT = Context.getBaseElementType(T);
if (!T->isDependentType() &&
+ !RequireCompleteType(Loc, BaseT, 0) &&
!BaseT.isPODType(Context) &&
!BaseT->isObjCLifetimeType()) {
Diag(Loc, diag::err_vla_non_pod)
diff --git a/clang/test/SemaCXX/vla.cpp b/clang/test/SemaCXX/vla.cpp
index d63b6335f45..dae6450553a 100644
--- a/clang/test/SemaCXX/vla.cpp
+++ b/clang/test/SemaCXX/vla.cpp
@@ -3,3 +3,17 @@
// PR11925
int n;
int (&f())[n]; // expected-error {{function declaration cannot have variably modified type}}
+
+namespace PR18581 {
+ template<typename T> struct pod {};
+ template<typename T> struct error {
+ typename T::error e; // expected-error {{cannot be used prior to '::'}}
+ };
+ struct incomplete; // expected-note {{forward declaration}}
+
+ void f(int n) {
+ pod<int> a[n];
+ error<int> b[n]; // expected-note {{instantiation}}
+ incomplete c[n]; // expected-error {{incomplete}}
+ }
+}
OpenPOWER on IntegriCloud