r201018 - PR18581: Attempt to complete the type in a VLA declaration before checking
Richard Smith
richard-llvm at metafoo.co.uk
Fri Feb 7 18:30:50 PST 2014
Author: rsmith
Date: Fri Feb 7 20:30:49 2014
New Revision: 201018
URL: http://llvm.org/viewvc/llvm-project?rev=201018&view=rev
Log:
PR18581: Attempt to complete the type in a VLA declaration before checking
whether it's POD.
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/vla.cpp
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=201018&r1=201017&r2=201018&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Feb 7 20:30:49 2014
@@ -1590,6 +1590,7 @@ QualType Sema::BuildArrayType(QualType T
// 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)
Modified: cfe/trunk/test/SemaCXX/vla.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/vla.cpp?rev=201018&r1=201017&r2=201018&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/vla.cpp (original)
+++ cfe/trunk/test/SemaCXX/vla.cpp Fri Feb 7 20:30:49 2014
@@ -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}}
+ }
+}
More information about the cfe-commits
mailing list