Skip to content

Commit c2a250e

Browse files
committed
[Concepts] Fix bug when referencing function parameters in instantiated function template requires clause
Fixes bug llvm#44613 - incorrect instantiated parameters were being added when checking instantiated function constraints
1 parent 1e4764e commit c2a250e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4252,9 +4252,9 @@ bool Sema::CheckInstantiatedFunctionTemplateConstraints(
42524252
MLTAL.getInnermost(), SourceRange());
42534253
if (Inst.isInvalid())
42544254
return true;
4255-
if (addInstantiatedParametersToScope(*this, Decl,
4256-
Decl->getTemplateInstantiationPattern(),
4257-
Scope, MLTAL))
4255+
if (addInstantiatedParametersToScope(
4256+
*this, Decl, Decl->getPrimaryTemplate()->getTemplatedDecl(),
4257+
Scope, MLTAL))
42584258
return true;
42594259
}
42604260

clang/test/SemaTemplate/instantiate-requires-clause.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,13 @@ using f31 = decltype(f3('a'));
2929
using f32 = decltype(f3(1, 'b'));
3030
using f33 = decltype(f3(1, 'b', 2));
3131
// expected-error@-1 {{no matching function for call to 'f3'}}
32+
33+
template<typename T>
34+
struct S {
35+
template<typename U>
36+
static constexpr auto f(U const index) requires(index, true) {
37+
return true;
38+
}
39+
};
40+
41+
static_assert(S<void>::f(1));

0 commit comments

Comments
 (0)