@@ -5502,10 +5502,6 @@ static TemplateDeductionResult CheckDeductionConsistency(
5502
5502
ArrayRef<TemplateArgument> DeducedArgs, bool CheckConsistency) {
5503
5503
MultiLevelTemplateArgumentList MLTAL (FTD, DeducedArgs,
5504
5504
/* Final=*/ true );
5505
- if (ArgIdx != -1 )
5506
- if (auto *MD = dyn_cast<CXXMethodDecl>(FTD->getTemplatedDecl ());
5507
- MD && MD->isImplicitObjectMemberFunction ())
5508
- ArgIdx -= 1 ;
5509
5505
Sema::ArgumentPackSubstitutionIndexRAII PackIndex (
5510
5506
S, ArgIdx != -1 ? ::getPackIndexForParam (S, FTD, MLTAL, ArgIdx) : -1 );
5511
5507
bool IsIncompleteSubstitution = false ;
@@ -5576,12 +5572,10 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction(
5576
5572
5577
5573
// / Determine whether the function template \p FT1 is at least as
5578
5574
// / specialized as \p FT2.
5579
- static bool isAtLeastAsSpecializedAs (Sema &S, SourceLocation Loc,
5580
- FunctionTemplateDecl *FT1,
5581
- FunctionTemplateDecl *FT2,
5582
- TemplatePartialOrderingContext TPOC,
5583
- ArrayRef<QualType> Args1,
5584
- ArrayRef<QualType> Args2) {
5575
+ static bool isAtLeastAsSpecializedAs (
5576
+ Sema &S, SourceLocation Loc, FunctionTemplateDecl *FT1,
5577
+ FunctionTemplateDecl *FT2, TemplatePartialOrderingContext TPOC,
5578
+ ArrayRef<QualType> Args1, ArrayRef<QualType> Args2, bool Args1Offset) {
5585
5579
FunctionDecl *FD1 = FT1->getTemplatedDecl ();
5586
5580
FunctionDecl *FD2 = FT2->getTemplatedDecl ();
5587
5581
const FunctionProtoType *Proto1 = FD1->getType ()->getAs <FunctionProtoType>();
@@ -5676,6 +5670,8 @@ static bool isAtLeastAsSpecializedAs(Sema &S, SourceLocation Loc,
5676
5670
TemplateDeductionInfo &Info,
5677
5671
SmallVectorImpl<DeducedTemplateArgument> &Deduced,
5678
5672
PartialOrderingKind) {
5673
+ if (ArgIdx != -1 )
5674
+ ArgIdx -= Args1Offset;
5679
5675
return ::CheckDeductionConsistency (
5680
5676
S, FTD, ArgIdx, P, A, DeducedArgs,
5681
5677
/* CheckConsistency=*/ HasDeducedParam[ParamIdx]);
@@ -5763,6 +5759,8 @@ FunctionTemplateDecl *Sema::getMoreSpecializedTemplate(
5763
5759
const FunctionDecl *FD2 = FT2->getTemplatedDecl ();
5764
5760
bool ShouldConvert1 = false ;
5765
5761
bool ShouldConvert2 = false ;
5762
+ bool Args1Offset = false ;
5763
+ bool Args2Offset = false ;
5766
5764
QualType Obj1Ty;
5767
5765
QualType Obj2Ty;
5768
5766
if (TPOC == TPOC_Call) {
@@ -5811,6 +5809,7 @@ FunctionTemplateDecl *Sema::getMoreSpecializedTemplate(
5811
5809
Obj1Ty = GetImplicitObjectParameterType (this ->Context , Method1,
5812
5810
RawObj1Ty, IsRValRef2);
5813
5811
Args1.push_back (Obj1Ty);
5812
+ Args1Offset = true ;
5814
5813
}
5815
5814
if (ShouldConvert2) {
5816
5815
bool IsRValRef1 =
@@ -5821,6 +5820,7 @@ FunctionTemplateDecl *Sema::getMoreSpecializedTemplate(
5821
5820
Obj2Ty = GetImplicitObjectParameterType (this ->Context , Method2,
5822
5821
RawObj2Ty, IsRValRef1);
5823
5822
Args2.push_back (Obj2Ty);
5823
+ Args2Offset = true ;
5824
5824
}
5825
5825
} else {
5826
5826
if (NonStaticMethod1 && Method1->hasCXXExplicitFunctionObjectParameter ())
@@ -5842,10 +5842,10 @@ FunctionTemplateDecl *Sema::getMoreSpecializedTemplate(
5842
5842
} else {
5843
5843
assert (!Reversed && " Only call context could have reversed arguments" );
5844
5844
}
5845
- bool Better1 =
5846
- isAtLeastAsSpecializedAs (* this , Loc, FT1, FT2, TPOC, Args1, Args2);
5847
- bool Better2 =
5848
- isAtLeastAsSpecializedAs (* this , Loc, FT2, FT1, TPOC, Args2, Args1);
5845
+ bool Better1 = isAtLeastAsSpecializedAs (* this , Loc, FT1, FT2, TPOC, Args1,
5846
+ Args2, Args2Offset );
5847
+ bool Better2 = isAtLeastAsSpecializedAs (* this , Loc, FT2, FT1, TPOC, Args2,
5848
+ Args1, Args1Offset );
5849
5849
// C++ [temp.deduct.partial]p10:
5850
5850
// F is more specialized than G if F is at least as specialized as G and G
5851
5851
// is not at least as specialized as F.
0 commit comments