Skip to content

Commit aa99ac4

Browse files
committed
[Clang][Concepts] Fix the constraint equivalence checking for TemplateTypeParmTypes
1 parent 3364284 commit aa99ac4

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,15 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
972972
// equivalence.
973973
LocalInstantiationScope ScopeForParameters(S);
974974
if (auto *FD = DeclInfo.getDecl()->getAsFunction())
975-
for (auto *PVD : FD->parameters())
976-
ScopeForParameters.InstantiatedLocal(PVD, PVD);
975+
for (auto *PVD : FD->parameters()) {
976+
if (!PVD->isParameterPack()) {
977+
ScopeForParameters.InstantiatedLocal(PVD, PVD);
978+
continue;
979+
}
980+
// Parameter packs should expand to a size-of-1 argument.
981+
ScopeForParameters.MakeInstantiatedLocalArgPack(PVD);
982+
ScopeForParameters.InstantiatedLocalPackArg(PVD, PVD);
983+
}
977984

978985
std::optional<Sema::CXXThisScopeRAII> ThisScope;
979986

clang/test/SemaTemplate/concepts-out-of-line-def.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,3 +599,26 @@ template <class DerT>
599599
unsigned long DerivedCollection<DerTs...>::index() {}
600600

601601
} // namespace GH72557
602+
603+
namespace GH101735 {
604+
605+
template <class, class>
606+
concept True = true;
607+
608+
template <typename T>
609+
class A {
610+
template <typename... Ts>
611+
void method(Ts&... ts)
612+
requires requires (T t) {
613+
{ t.method(static_cast<Ts &&>(ts)...) } -> True<void>;
614+
};
615+
};
616+
617+
template <typename T>
618+
template <typename... Ts>
619+
void A<T>::method(Ts&... ts)
620+
requires requires (T t) {
621+
{ t.method(static_cast<Ts &&>(ts)...) } -> True<void>;
622+
} {}
623+
624+
}

0 commit comments

Comments
 (0)