rZhBoYao updated this revision to Diff 392774. rZhBoYao edited the summary of this revision. rZhBoYao added a comment.
I added a test. There were 17 module and PCH related failed tests on my local machine; however, when I ran the test on then ToT <https://github.com/llvm/llvm-project/commit/9ae5810b53c2e096d7442ba8af3f00ebc3d301b0> the same 17 tests failed, but on GitHub <https://github.com/llvm/llvm-project/commit/9ae5810b53c2e096d7442ba8af3f00ebc3d301b0> it does show 2 successful checks. So maybe it's something else. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115248/new/ https://reviews.llvm.org/D115248 Files: clang/lib/Parse/ParseDecl.cpp clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp 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 <class C> virtual void g(C); // expected-error{{'virtual' cannot be specified on member function templates}} virtual void f(); }; + +template <typename T> +class PR28101 { +public: + PR28101(void *) {} + T(PR28101<T>){}; // expected-error{{member 'PR28101' has the same name as its class}} \ + // expected-error{{member 'PR28101' has the same name as its class}} +}; + +PR28101<int> foo() { return new int; } // expected-note{{in instantiation of template class 'PR28101<int>' requested here}} 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 <class C> virtual void g(C); // expected-error{{'virtual' cannot be specified on member function templates}} virtual void f(); }; + +template <typename T> +class PR28101 { +public: + PR28101(void *) {} + T(PR28101<T>){}; // expected-error{{member 'PR28101' has the same name as its class}} \ + // expected-error{{member 'PR28101' has the same name as its class}} +}; + +PR28101<int> foo() { return new int; } // expected-note{{in instantiation of template class 'PR28101<int>' requested here}} 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; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits