@@ -11080,11 +11080,6 @@ OverloadCandidateSet::ResultForBestCandidate(const iterator &Best) {
11080
11080
Best->Best = true;
11081
11081
if (Best->Function && Best->Function->isDeleted())
11082
11082
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
- }
11088
11083
return OR_Success;
11089
11084
}
11090
11085
@@ -14572,10 +14567,12 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
14572
14567
Expr *ExecConfig,
14573
14568
bool AllowTypoCorrection,
14574
14569
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);
14579
14576
ExprResult result;
14580
14577
14581
14578
if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
@@ -14591,6 +14588,17 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
14591
14588
OverloadingResult OverloadResult =
14592
14589
CandidateSet.BestViableFunction(*this, Fn->getBeginLoc(), Best);
14593
14590
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
+
14594
14602
// Model the case with a call to a templated function whose definition
14595
14603
// encloses the call and whose return type contains a placeholder type as if
14596
14604
// the UnresolvedLookupExpr was type-dependent.
0 commit comments