Skip to content

Commit c853676

Browse files
authored
[Clang] Fix a crash when incorrectly calling an explicit object member function template (#75913)
Fixes #75732
1 parent f709642 commit c853676

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clang/lib/Sema/SemaExprMember.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ static void diagnoseInstanceReference(Sema &SemaRef,
253253
SemaRef.Diag(Loc, diag::err_member_call_without_object)
254254
<< Range << /*static*/ 0;
255255
else {
256-
const auto *Callee = dyn_cast<CXXMethodDecl>(Rep);
256+
if (const auto *Tpl = dyn_cast<FunctionTemplateDecl>(Rep))
257+
Rep = Tpl->getTemplatedDecl();
258+
const auto *Callee = cast<CXXMethodDecl>(Rep);
257259
auto Diag = SemaRef.Diag(Loc, diag::err_member_call_without_object)
258260
<< Range << Callee->isExplicitObjectMemberFunction();
259261
if (!Replacement.empty())

clang/test/SemaCXX/cxx2b-deducing-this.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,3 +626,13 @@ void test() {
626626
}
627627

628628
}
629+
630+
631+
namespace GH75732 {
632+
auto serialize(auto&& archive, auto&& c){ }
633+
struct D {
634+
auto serialize(this auto&& self, auto&& archive) {
635+
serialize(archive, self); // expected-error {{call to explicit member function without an object argument}}
636+
}
637+
};
638+
}

0 commit comments

Comments
 (0)