diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 2f2c06bb72de05..8fd7491c45e323 100755 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4252,9 +4252,9 @@ bool Sema::CheckInstantiatedFunctionTemplateConstraints( MLTAL.getInnermost(), SourceRange()); if (Inst.isInvalid()) return true; - if (addInstantiatedParametersToScope(*this, Decl, - Decl->getTemplateInstantiationPattern(), - Scope, MLTAL)) + if (addInstantiatedParametersToScope( + *this, Decl, Decl->getPrimaryTemplate()->getTemplatedDecl(), + Scope, MLTAL)) return true; } diff --git a/clang/test/SemaTemplate/instantiate-requires-clause.cpp b/clang/test/SemaTemplate/instantiate-requires-clause.cpp index f36396b98db735..04b595717e6d55 100644 --- a/clang/test/SemaTemplate/instantiate-requires-clause.cpp +++ b/clang/test/SemaTemplate/instantiate-requires-clause.cpp @@ -29,3 +29,13 @@ using f31 = decltype(f3('a')); using f32 = decltype(f3(1, 'b')); using f33 = decltype(f3(1, 'b', 2)); // expected-error@-1 {{no matching function for call to 'f3'}} + +template +struct S { + template + static constexpr auto f(U const index) requires(index, true) { + return true; + } +}; + +static_assert(S::f(1));