@@ -7554,11 +7554,16 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
7554
7554
(Method->isExplicitObjectMemberFunction() &&
7555
7555
CandidateSet.getKind() ==
7556
7556
OverloadCandidateSet::CSK_AddressOfOverloadSet);
7557
+ bool ImplicitObjectMethodTreatedAsStatic =
7558
+ CandidateSet.getKind() ==
7559
+ OverloadCandidateSet::CSK_AddressOfOverloadSet &&
7560
+ Method->isImplicitObjectMemberFunction();
7561
+
7557
7562
unsigned ExplicitOffset =
7558
7563
!IgnoreExplicitObject && Method->isExplicitObjectMemberFunction() ? 1 : 0;
7559
- unsigned NumParams = Method->getNumParams() - ExplicitOffset;
7560
- if (CandidateSet.getKind() == OverloadCandidateSet::CSK_AddressOfOverloadSet)
7561
- NumParams += int(Method->isImplicitObjectMemberFunction() );
7564
+
7565
+ unsigned NumParams = Method->getNumParams() - ExplicitOffset +
7566
+ int(ImplicitObjectMethodTreatedAsStatic );
7562
7567
7563
7568
// (C++ 13.3.2p2): A candidate function having fewer than m
7564
7569
// parameters is viable only if it has an ellipsis in its parameter
@@ -7576,11 +7581,9 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
7576
7581
// (8.3.6). For the purposes of overload resolution, the
7577
7582
// parameter list is truncated on the right, so that there are
7578
7583
// exactly m parameters.
7579
- unsigned MinRequiredArgs = Method->getMinRequiredArguments() - ExplicitOffset;
7580
- if (CandidateSet.getKind() ==
7581
- OverloadCandidateSet::CSK_AddressOfOverloadSet &&
7582
- Method->isImplicitObjectMemberFunction())
7583
- MinRequiredArgs++;
7584
+ unsigned MinRequiredArgs = Method->getMinRequiredArguments() -
7585
+ ExplicitOffset +
7586
+ int(ImplicitObjectMethodTreatedAsStatic);
7584
7587
7585
7588
if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7586
7589
// Not enough arguments.
@@ -7652,9 +7655,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
7652
7655
// (13.3.3.1) that converts that argument to the corresponding
7653
7656
// parameter of F.
7654
7657
QualType ParamType;
7655
- if (CandidateSet.getKind() ==
7656
- OverloadCandidateSet::CSK_AddressOfOverloadSet &&
7657
- Method->isImplicitObjectMemberFunction()) {
7658
+ if (ImplicitObjectMethodTreatedAsStatic) {
7658
7659
ParamType = ArgIdx == 0
7659
7660
? Method->getFunctionObjectParameterReferenceType()
7660
7661
: Proto->getParamType(ArgIdx - 1);
@@ -16402,8 +16403,8 @@ ExprResult Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
16402
16403
"Can only take the address of an overloaded function");
16403
16404
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Fn)) {
16404
16405
if (!Method->isImplicitObjectMemberFunction()) {
16405
- // Do nothing: static member functions aren't any different
16406
- // from non-member functions .
16406
+ // Do nothing: the address of static and
16407
+ // explicit object member functions is a ( non-member) function pointer .
16407
16408
} else {
16408
16409
// Fix the subexpression, which really has to be an
16409
16410
// UnresolvedLookupExpr holding an overloaded member function
0 commit comments