[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 11 14:14:47 PST 2024
================
@@ -4008,6 +3996,38 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction(
Owner = FunctionTemplate->getLexicalDeclContext();
FunctionDecl *FD = FunctionTemplate->getTemplatedDecl();
+ // C++20 [temp.deduct.general]p5: (CWG2369)
+ // If the function template has associated constraints, those constraints are
+ // checked for satisfaction. If the constraints are not satisfied, type
+ // deduction fails.
+ // FIXME: We haven't implemented CWG2369 for lambdas yet, because we need
+ // to figure out how to instantiate lambda captures to the scope without
+ // first instantiating the lambda.
+ bool IsLambda = isLambdaCallOperator(FD) || isLambdaConversionOperator(FD);
+ if (!IsLambda && !IsIncomplete) {
+ if (CheckFunctionTemplateConstraints(
+ Info.getLocation(),
+ FunctionTemplate->getCanonicalDecl()->getTemplatedDecl(),
+ CanonicalBuilder, Info.AssociatedConstraintsSatisfaction))
+ return TemplateDeductionResult::MiscellaneousDeductionFailure;
+ if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) {
+ Info.reset(Info.takeSugared(),
+ TemplateArgumentList::CreateCopy(Context, CanonicalBuilder));
----------------
mizvekov wrote:
Yeah, what @zyn0217 said is correct, the canonical argument list will have references persist in AST nodes, so it needs to be copied here.
https://github.com/llvm/llvm-project/pull/102857
More information about the cfe-commits
mailing list