-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang] Fix a crash when incorrectly calling an explicit object member function template #75913
Conversation
…r function template Fixes llvm#75732
@llvm/pr-subscribers-clang Author: cor3ntin (cor3ntin) ChangesFixes #75732 Full diff: https://github.com/llvm/llvm-project/pull/75913.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 473eea55bb6b19..0e932a1436d6e0 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -253,6 +253,8 @@ static void diagnoseInstanceReference(Sema &SemaRef,
SemaRef.Diag(Loc, diag::err_member_call_without_object)
<< Range << /*static*/ 0;
else {
+ if (auto *Tpl = dyn_cast<FunctionTemplateDecl>(Rep))
+ Rep = Tpl->getTemplatedDecl();
const auto *Callee = dyn_cast<CXXMethodDecl>(Rep);
auto Diag = SemaRef.Diag(Loc, diag::err_member_call_without_object)
<< Range << Callee->isExplicitObjectMemberFunction();
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 0033541fa322dc..aab35828096a8e 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -626,3 +626,13 @@ void test() {
}
}
+
+
+namespace GH75732 {
+auto serialize(auto&& archive, auto&& c){ }
+struct D {
+ auto serialize(this auto&& self, auto&& archive) {
+ serialize(archive, self); // expected-error {{call to explicit member function without an object argument}}
+ }
+};
+}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a little NIT
clang/lib/Sema/SemaExprMember.cpp
Outdated
@@ -253,7 +253,9 @@ static void diagnoseInstanceReference(Sema &SemaRef, | |||
SemaRef.Diag(Loc, diag::err_member_call_without_object) | |||
<< Range << /*static*/ 0; | |||
else { | |||
const auto *Callee = dyn_cast<CXXMethodDecl>(Rep); | |||
if (auto *Tpl = dyn_cast<FunctionTemplateDecl>(Rep)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a const can be added here.
Fixes #75732