Commit 9fbd4ab3 authored by Saar Raz's avatar Saar Raz
Browse files

[Concepts] Do not check constraints if not all template arguments have been deduced

We previously checked the constraints of instantiated function templates even in cases where
PartialOverloading was true and not all template arguments have been deduced, which caused crashes
in clangd (bug 44714).

We now check if all arguments have been deduced before checking constraints in partial overloading
scenarios.

(cherry picked from commit 5fef14d9)
parent 2804f355
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -3439,6 +3439,8 @@ Sema::TemplateDeductionResult Sema::FinishTemplateArgumentDeduction(
  //   ([temp.constr.decl]), those constraints are checked for satisfaction
  //   ([temp.constr.constr]). If the constraints are not satisfied, type
  //   deduction fails.
  if (!PartialOverloading ||
      (Builder.size() == FunctionTemplate->getTemplateParameters()->size())) {
    if (CheckInstantiatedFunctionTemplateConstraints(Info.getLocation(),
            Specialization, Builder, Info.AssociatedConstraintsSatisfaction))
      return TDK_MiscellaneousDeductionFailure;
@@ -3447,6 +3449,7 @@ Sema::TemplateDeductionResult Sema::FinishTemplateArgumentDeduction(
      Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
      return TDK_ConstraintsNotSatisfied;
    }
  }

  if (OriginalCallArgs) {
    // C++ [temp.deduct.call]p4:
+6 −0
Original line number Diff line number Diff line
// RUN:  %clang_cc1 -std=c++2a -verify %s -code-completion-at=%s:6:16
// expected-no-diagnostics

template <typename T> concept C = true;
void bar(C auto foo);
int y = bar(
 No newline at end of file