forked from OSchip/llvm-project
PR18581: Attempt to complete the type in a VLA declaration before checking
whether it's POD. llvm-svn: 201018
This commit is contained in:
parent
18066822a8
commit
04d6d2f2af
|
@ -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)
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue