Skip to content

Commit 477d531

Browse files
committed
move and document the special handling of implicit object member function in non-member calls
1 parent 5f90891 commit 477d531

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
@@ -11080,11 +11080,6 @@ OverloadCandidateSet::ResultForBestCandidate(const iterator &Best) {
1108011080
Best->Best = true;
1108111081
if (Best->Function && Best->Function->isDeleted())
1108211082
return OR_Deleted;
11083-
if (auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
11084-
Kind == CSK_AddressOfOverloadSet && M &&
11085-
M->isImplicitObjectMemberFunction()) {
11086-
return OR_No_Viable_Function;
11087-
}
1108811083
return OR_Success;
1108911084
}
1109011085

@@ -14572,10 +14567,12 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
1457214567
Expr *ExecConfig,
1457314568
bool AllowTypoCorrection,
1457414569
bool CalleesAddressIsTaken) {
14575-
OverloadCandidateSet CandidateSet(
14576-
Fn->getExprLoc(), CalleesAddressIsTaken
14577-
? OverloadCandidateSet::CSK_AddressOfOverloadSet
14578-
: OverloadCandidateSet::CSK_Normal);
14570+
14571+
OverloadCandidateSet::CandidateSetKind CSK =
14572+
CalleesAddressIsTaken ? OverloadCandidateSet::CSK_AddressOfOverloadSet
14573+
: OverloadCandidateSet::CSK_Normal;
14574+
14575+
OverloadCandidateSet CandidateSet(Fn->getExprLoc(), CSK);
1457914576
ExprResult result;
1458014577

1458114578
if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
@@ -14591,6 +14588,17 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
1459114588
OverloadingResult OverloadResult =
1459214589
CandidateSet.BestViableFunction(*this, Fn->getBeginLoc(), Best);
1459314590

14591+
// [C++23][over.call.func]
14592+
// if overload resolution selects a non-static member function,
14593+
// the call is ill-formed;
14594+
if (CSK == OverloadCandidateSet::CSK_AddressOfOverloadSet &&
14595+
Best != CandidateSet.end()) {
14596+
if (auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
14597+
M && M->isImplicitObjectMemberFunction()) {
14598+
OverloadResult = OR_No_Viable_Function;
14599+
}
14600+
}
14601+
1459414602
// Model the case with a call to a templated function whose definition
1459514603
// encloses the call and whose return type contains a placeholder type as if
1459614604
// the UnresolvedLookupExpr was type-dependent.

0 commit comments

Comments
 (0)