@@ -10338,6 +10338,25 @@ bool Sema::CheckFunctionTemplateSpecialization(
10338
10338
return false ;
10339
10339
}
10340
10340
10341
+ static bool IsMoreConstrainedFunction (Sema &S, FunctionDecl *FD1,
10342
+ FunctionDecl *FD2) {
10343
+ if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction ())
10344
+ FD1 = MF;
10345
+ if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction ())
10346
+ FD2 = MF;
10347
+ llvm::SmallVector<const Expr *, 3 > AC1, AC2;
10348
+ FD1->getAssociatedConstraints (AC1);
10349
+ FD2->getAssociatedConstraints (AC2);
10350
+ bool AtLeastAsConstrained1, AtLeastAsConstrained2;
10351
+ if (S.IsAtLeastAsConstrained (FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
10352
+ return false ;
10353
+ if (S.IsAtLeastAsConstrained (FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
10354
+ return false ;
10355
+ if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
10356
+ return false ;
10357
+ return AtLeastAsConstrained1;
10358
+ }
10359
+
10341
10360
// / Perform semantic analysis for the given non-template member
10342
10361
// / specialization.
10343
10362
// /
@@ -10372,15 +10391,26 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
10372
10391
QualType Adjusted = Function->getType ();
10373
10392
if (!hasExplicitCallingConv (Adjusted))
10374
10393
Adjusted = adjustCCAndNoReturn (Adjusted, Method->getType ());
10394
+ if (!Context.hasSameType (Adjusted, Method->getType ()))
10395
+ continue ;
10396
+ if (Method->getTrailingRequiresClause ()) {
10397
+ ConstraintSatisfaction Satisfaction;
10398
+ if (CheckFunctionConstraints (Method, Satisfaction,
10399
+ /* UsageLoc=*/ Member->getLocation (),
10400
+ /* ForOverloadResolution=*/ true ) ||
10401
+ !Satisfaction.IsSatisfied )
10402
+ continue ;
10403
+ if (Instantiation &&
10404
+ !IsMoreConstrainedFunction (*this , Method,
10405
+ cast<CXXMethodDecl>(Instantiation)))
10406
+ continue ;
10407
+ }
10375
10408
// This doesn't handle deduced return types, but both function
10376
10409
// declarations should be undeduced at this point.
10377
- if (Context.hasSameType (Adjusted, Method->getType ())) {
10378
- FoundInstantiation = *I;
10379
- Instantiation = Method;
10380
- InstantiatedFrom = Method->getInstantiatedFromMemberFunction ();
10381
- MSInfo = Method->getMemberSpecializationInfo ();
10382
- break ;
10383
- }
10410
+ FoundInstantiation = *I;
10411
+ Instantiation = Method;
10412
+ InstantiatedFrom = Method->getInstantiatedFromMemberFunction ();
10413
+ MSInfo = Method->getMemberSpecializationInfo ();
10384
10414
}
10385
10415
}
10386
10416
} else if (isa<VarDecl>(Member)) {
0 commit comments