Author: rsmith Date: Wed Jan 4 17:45:01 2017 New Revision: 291034 URL: http://llvm.org/viewvc/llvm-project?rev=291034&view=rev Log: Only instantiate members of nested classes in local classes once, rather than once per enclosing class.
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=291034&r1=291033&r2=291034&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Jan 4 17:45:01 2017 @@ -1470,8 +1470,11 @@ Decl *TemplateDeclInstantiator::VisitCXX 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. Modified: cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp?rev=291034&r1=291033&r2=291034&view=diff ============================================================================== --- cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp (original) +++ cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp Wed Jan 4 17:45:01 2017 @@ -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>(); } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits