[PATCH] D115248: [clang] Fix Bug 28101

PoYao Chang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 8 07:42:52 PST 2021


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;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115248.392774.patch
Type: text/x-patch
Size: 1331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211208/294b2145/attachment.bin>


More information about the cfe-commits mailing list