]> granicus.if.org Git - clang/commitdiff
PR18581: Attempt to complete the type in a VLA declaration before checking
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 8 Feb 2014 02:30:49 +0000 (02:30 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 8 Feb 2014 02:30:49 +0000 (02:30 +0000)
whether it's POD.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201018 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/SemaCXX/vla.cpp

index c2ff2238d5fd105c7867c2bf7e52ed89e1084db2..f9f6cee994ecfa3fb16636f7cacb5526ff33900d 100644 (file)
@@ -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)
index d63b6335f453350b98af20d7dd71d733823f4c89..dae6450553aa364f53ccdcce51a5762a3dac2fcd 100644 (file)
@@ -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}}
+  }
+}