[clang] c853676 - [Clang] Fix a crash when incorrectly calling an explicit object member function template (#75913)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 19 22:41:28 PST 2023
Author: cor3ntin
Date: 2023-12-20T07:41:24+01:00
New Revision: c8536760612785e8ee97a5261c20d22c6712b4b2
URL: https://github.com/llvm/llvm-project/commit/c8536760612785e8ee97a5261c20d22c6712b4b2
DIFF: https://github.com/llvm/llvm-project/commit/c8536760612785e8ee97a5261c20d22c6712b4b2.diff
LOG: [Clang] Fix a crash when incorrectly calling an explicit object member function template (#75913)
Fixes #75732
Added:
Modified:
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaCXX/cxx2b-deducing-this.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 473eea55bb6b19..2abec3d86a27d9 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -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 (const auto *Tpl = dyn_cast<FunctionTemplateDecl>(Rep))
+ Rep = Tpl->getTemplatedDecl();
+ const auto *Callee = cast<CXXMethodDecl>(Rep);
auto Diag = SemaRef.Diag(Loc, diag::err_member_call_without_object)
<< Range << Callee->isExplicitObjectMemberFunction();
if (!Replacement.empty())
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}}
+ }
+};
+}
More information about the cfe-commits
mailing list