Skip to content

Commit b39efdb

Browse files
committed
[Concepts] Fix incorrect TemplateArgs for introduction of local parameters
The wrong set of TemplateArgs was being provided to addInstantiatedParametersToScope. Caused bug #44658. (cherry picked from commit 9c24fca)
1 parent b07b827 commit b39efdb

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4246,18 +4246,17 @@ bool Sema::CheckInstantiatedFunctionTemplateConstraints(
42464246
Sema::ContextRAII savedContext(*this, Decl);
42474247
LocalInstantiationScope Scope(*this);
42484248

4249-
MultiLevelTemplateArgumentList MLTAL =
4250-
getTemplateInstantiationArgs(Decl, nullptr, /*RelativeToPrimary*/true);
4251-
42524249
// If this is not an explicit specialization - we need to get the instantiated
42534250
// version of the template arguments and add them to scope for the
42544251
// substitution.
42554252
if (Decl->isTemplateInstantiation()) {
42564253
InstantiatingTemplate Inst(*this, Decl->getPointOfInstantiation(),
42574254
InstantiatingTemplate::ConstraintsCheck{}, Decl->getPrimaryTemplate(),
4258-
MLTAL.getInnermost(), SourceRange());
4255+
TemplateArgs, SourceRange());
42594256
if (Inst.isInvalid())
42604257
return true;
4258+
MultiLevelTemplateArgumentList MLTAL(
4259+
*Decl->getTemplateSpecializationArgs());
42614260
if (addInstantiatedParametersToScope(
42624261
*this, Decl, Decl->getPrimaryTemplate()->getTemplatedDecl(),
42634262
Scope, MLTAL))

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,10 @@ struct S2 {
5151

5252
static_assert((S2<int>::f(), true));
5353

54+
template<typename T>
55+
struct S3 {
56+
template<typename... Args> requires true
57+
static constexpr void f(Args...) { }
58+
};
59+
60+
static_assert((S3<int>::f(), true));

0 commit comments

Comments
 (0)