[PATCH] D115248: [clang] Fix PR28101
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 13 11:30:10 PST 2021
aaron.ballman added inline comments.
================
Comment at: clang/lib/Parse/ParseDecl.cpp:6485-6488
+ if (getLangOpts().CPlusPlus && !D.getIdentifier() &&
+ D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId &&
+ D.getContext() == DeclaratorContext::Member)
+ D.SetIdentifier(D.getName().TemplateId->Name, D.getName().getBeginLoc());
----------------
This fix looks incredibly specific to the bug report, how does it handle other situations, like:
```
template <typename T, template <typename> typename U>
class PR28101 {
public:
PR28101(void *) {}
T(PR28101<T, U<T>>) {} // Do we err here?
};
template <typename T>
struct S {};
PR28101<int, S> foo() { return PR28101<int, S>(nullptr); }
```
================
Comment at: clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp:12-13
+ 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}}
+};
----------------
It seems incorrect that we're issuing the same diagnostic twice. Is this because of template instantiation, or some other reason?
================
Comment at: clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp:16
+
+PR28101<int> foo() { return new int; } // expected-note{{in instantiation of template class 'PR28101<int>' requested here}}
----------------
The test location is a bit novel -- [temp.mem]p3 is "A member function template shall not be declared virtual." and I don't see anything related to p3 in this test. I think the test case is reasonable enough, but it should probably live in SemaCXX instead of here.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115248/new/
https://reviews.llvm.org/D115248
More information about the cfe-commits
mailing list