Skip to content

Commit af3cf01

Browse files
committed
move and document the special handling of implicit object member function in non-member calls
1 parent 37a8ea9 commit af3cf01

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

clang/include/clang/Sema/Overload.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,9 +1448,8 @@ class Sema;
14481448
// For user defined conversion we need to check against different
14491449
// combination of CV qualifiers and look at any expicit specifier, so
14501450
// always deduce template candidate.
1451-
Kind != CSK_InitByUserDefinedConversion
1452-
&& Kind != CSK_InitByConstructor
1453-
&& Kind != CSK_CodeCompletion &&
1451+
Kind != CSK_InitByUserDefinedConversion &&
1452+
Kind != CSK_InitByConstructor && Kind != CSK_CodeCompletion &&
14541453
Opts.CPlusPlus && (!Opts.CUDA || Opts.GPUExcludeWrongSideOverloads);
14551454
}
14561455

clang/lib/Sema/SemaOverload.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11088,11 +11088,6 @@ OverloadCandidateSet::ResultForBestCandidate(const iterator &Best) {
1108811088
Best->Best = true;
1108911089
if (Best->Function && Best->Function->isDeleted())
1109011090
return OR_Deleted;
11091-
if (auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
11092-
Kind == CSK_AddressOfOverloadSet && M &&
11093-
M->isImplicitObjectMemberFunction()) {
11094-
return OR_No_Viable_Function;
11095-
}
1109611091
return OR_Success;
1109711092
}
1109811093

@@ -14591,10 +14586,12 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
1459114586
Expr *ExecConfig,
1459214587
bool AllowTypoCorrection,
1459314588
bool CalleesAddressIsTaken) {
14594-
OverloadCandidateSet CandidateSet(
14595-
Fn->getExprLoc(), CalleesAddressIsTaken
14596-
? OverloadCandidateSet::CSK_AddressOfOverloadSet
14597-
: OverloadCandidateSet::CSK_Normal);
14589+
14590+
OverloadCandidateSet::CandidateSetKind CSK =
14591+
CalleesAddressIsTaken ? OverloadCandidateSet::CSK_AddressOfOverloadSet
14592+
: OverloadCandidateSet::CSK_Normal;
14593+
14594+
OverloadCandidateSet CandidateSet(Fn->getExprLoc(), CSK);
1459814595
ExprResult result;
1459914596

1460014597
if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
@@ -14610,6 +14607,17 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
1461014607
OverloadingResult OverloadResult =
1461114608
CandidateSet.BestViableFunction(*this, Fn->getBeginLoc(), Best);
1461214609

14610+
// [C++23][over.call.func]
14611+
// if overload resolution selects a non-static member function,
14612+
// the call is ill-formed;
14613+
if (CSK == OverloadCandidateSet::CSK_AddressOfOverloadSet &&
14614+
Best != CandidateSet.end()) {
14615+
if (auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
14616+
M && M->isImplicitObjectMemberFunction()) {
14617+
OverloadResult = OR_No_Viable_Function;
14618+
}
14619+
}
14620+
1461314621
// Model the case with a call to a templated function whose definition
1461414622
// encloses the call and whose return type contains a placeholder type as if
1461514623
// the UnresolvedLookupExpr was type-dependent.

0 commit comments

Comments
 (0)