forked from OSchip/llvm-project
Diagnose unexpanded parameter packs in member initialisers (including
in-class member initialisers). llvm-svn: 142758
This commit is contained in:
parent
05156e3231
commit
9f58d7b789
|
@ -1635,6 +1635,12 @@ Sema::ActOnCXXInClassMemberInitializer(Decl *D, SourceLocation EqualLoc,
|
|||
return;
|
||||
}
|
||||
|
||||
if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
|
||||
FD->setInvalidDecl();
|
||||
FD->removeInClassInitializer();
|
||||
return;
|
||||
}
|
||||
|
||||
ExprResult Init = InitExpr;
|
||||
if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent()) {
|
||||
// FIXME: if there is no EqualLoc, this is list-initialization.
|
||||
|
@ -2031,6 +2037,9 @@ Sema::BuildMemberInitializer(ValueDecl *Member,
|
|||
assert((DirectMember || IndirectMember) &&
|
||||
"Member must be a FieldDecl or IndirectFieldDecl");
|
||||
|
||||
if (Args.DiagnoseUnexpandedParameterPack(*this))
|
||||
return true;
|
||||
|
||||
if (Member->isInvalidDecl())
|
||||
return true;
|
||||
|
||||
|
|
|
@ -189,6 +189,12 @@ struct TestUnexpandedDecls : T{
|
|||
T list_init = { static_cast<Types>(0) }; // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
|
||||
}
|
||||
|
||||
T in_class_member_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
|
||||
TestUnexpandedDecls() :
|
||||
Types(static_cast<Types>(0)), // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
|
||||
Types(static_cast<Types>(0))...,
|
||||
in_class_member_init(static_cast<Types>(0)) {} // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
|
||||
|
||||
void default_function_args(T = static_cast<Types>(0)); // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
|
||||
|
||||
template<typename = Types*> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
|
||||
|
|
Loading…
Reference in New Issue