PR18581: Attempt to complete the type in a VLA declaration before checking

whether it's POD.

llvm-svn: 201018
This commit is contained in:
Richard Smith 2014-02-08 02:30:49 +00:00
parent 18066822a8
commit 04d6d2f2af
2 changed files with 15 additions and 0 deletions

View 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)

View 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}}
}
}