================ @@ -3876,6 +3864,41 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( FD = const_cast<FunctionDecl *>(FDFriend); Owner = FD->getLexicalDeclContext(); } + + // C++20 [temp.deduct.general]p5: [DR2369] + // If the function template has associated constraints, those constraints are + // checked for satisfaction. If the constraints are not satisfied, type + // deduction fails. + bool NeedConstraintChecking = + !PartialOverloading || + CanonicalBuilder.size() == + FunctionTemplate->getTemplateParameters()->size(); + // FIXME: We haven't implemented DR2369 for lambdas yet, because we need + // the captured variables to be instantiated in the scope. + bool IsLambda = isLambdaCallOperator(FD) || isLambdaConversionOperator(FD); + if (!IsLambda && NeedConstraintChecking) { + if (CheckFunctionConstraintsWithoutInstantiation( + Info.getLocation(), FunctionTemplate->getCanonicalDecl(), + CanonicalBuilder, Info.AssociatedConstraintsSatisfaction)) + return TemplateDeductionResult::MiscellaneousDeductionFailure; + if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) { + Info.reset(Info.takeSugared(), + TemplateArgumentList::CreateCopy(Context, CanonicalBuilder)); + return TemplateDeductionResult::ConstraintsNotSatisfied; + } + } + // C++ [temp.deduct.call]p10: [DR1391] ---------------- cor3ntin wrote:
```suggestion // C++ [temp.deduct.call]p10 (CWG1391): ``` https://github.com/llvm/llvm-project/pull/102857 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits