@@ -11088,11 +11088,6 @@ OverloadCandidateSet::ResultForBestCandidate(const iterator &Best) {
11088
11088
Best->Best = true;
11089
11089
if (Best->Function && Best->Function->isDeleted())
11090
11090
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
- }
11096
11091
return OR_Success;
11097
11092
}
11098
11093
@@ -14591,10 +14586,12 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
14591
14586
Expr *ExecConfig,
14592
14587
bool AllowTypoCorrection,
14593
14588
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);
14598
14595
ExprResult result;
14599
14596
14600
14597
if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
@@ -14610,6 +14607,17 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
14610
14607
OverloadingResult OverloadResult =
14611
14608
CandidateSet.BestViableFunction(*this, Fn->getBeginLoc(), Best);
14612
14609
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
+
14613
14621
// Model the case with a call to a templated function whose definition
14614
14622
// encloses the call and whose return type contains a placeholder type as if
14615
14623
// the UnresolvedLookupExpr was type-dependent.
0 commit comments