Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -6482,6 +6482,11 @@ if (EllipsisLoc.isValid()) DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, D); + if (getLangOpts().CPlusPlus && !D.getIdentifier() && + D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId && + D.getContext() == DeclaratorContext::Member) + D.SetIdentifier(D.getName().TemplateId->Name, D.getName().getBeginLoc()); + return; } Index: clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp =================================================================== --- clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp +++ clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp @@ -4,3 +4,13 @@ template virtual void g(C); // expected-error{{'virtual' cannot be specified on member function templates}} virtual void f(); }; + +template +class PR28101 { +public: + PR28101(void *) {} + T(PR28101){}; // expected-error{{member 'PR28101' has the same name as its class}} \ + // expected-error{{member 'PR28101' has the same name as its class}} +}; + +PR28101 foo() { return new int; } // expected-note{{in instantiation of template class 'PR28101' requested here}}