forked from OSchip/llvm-project
[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.
This commit is contained in:
parent
cd515a6538
commit
5fef14d932
|
@ -3439,13 +3439,16 @@ 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 (CheckInstantiatedFunctionTemplateConstraints(Info.getLocation(),
|
||||
Specialization, Builder, Info.AssociatedConstraintsSatisfaction))
|
||||
return TDK_MiscellaneousDeductionFailure;
|
||||
if (!PartialOverloading ||
|
||||
(Builder.size() == FunctionTemplate->getTemplateParameters()->size())) {
|
||||
if (CheckInstantiatedFunctionTemplateConstraints(Info.getLocation(),
|
||||
Specialization, Builder, Info.AssociatedConstraintsSatisfaction))
|
||||
return TDK_MiscellaneousDeductionFailure;
|
||||
|
||||
if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) {
|
||||
Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
|
||||
return TDK_ConstraintsNotSatisfied;
|
||||
if (!Info.AssociatedConstraintsSatisfaction.IsSatisfied) {
|
||||
Info.reset(TemplateArgumentList::CreateCopy(Context, Builder));
|
||||
return TDK_ConstraintsNotSatisfied;
|
||||
}
|
||||
}
|
||||
|
||||
if (OriginalCallArgs) {
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// 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(
|
Loading…
Reference in New Issue