Only instantiate members of nested classes in local classes once, rather than once per enclosing class.

llvm-svn: 291034
This commit is contained in:
Richard Smith 2017-01-04 23:45:01 +00:00
parent dd9c27b3bf
commit ece4758bf2
2 changed files with 16 additions and 2 deletions

View File

@ -1470,8 +1470,11 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) {
TSK_ImplicitInstantiation,
/*Complain=*/true);
SemaRef.InstantiateClassMembers(D->getLocation(), Record, TemplateArgs,
TSK_ImplicitInstantiation);
// For nested local classes, we will instantiate the members when we
// reach the end of the outermost (non-nested) local class.
if (!D->isCXXClassMember())
SemaRef.InstantiateClassMembers(D->getLocation(), Record, TemplateArgs,
TSK_ImplicitInstantiation);
// This class may have local implicit instantiations that need to be
// performed within this scope.

View File

@ -475,3 +475,14 @@ namespace rdar23721638 {
}
template void bar<A>(); // expected-note {{in instantiation}}
}
namespace anon_union_default_member_init {
template<typename T> void f() {
struct S {
union {
int i = 0;
};
};
}
void g() { f<int>(); }
}