[clang] [Clang][Concepts] Fix the constraint equivalence checking involving parameter packs (PR #102131)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 23 23:10:42 PDT 2024
================
@@ -972,8 +972,15 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
// equivalence.
LocalInstantiationScope ScopeForParameters(S);
if (auto *FD = DeclInfo.getDecl()->getAsFunction())
- for (auto *PVD : FD->parameters())
- ScopeForParameters.InstantiatedLocal(PVD, PVD);
+ for (auto *PVD : FD->parameters()) {
+ if (!PVD->isParameterPack()) {
+ ScopeForParameters.InstantiatedLocal(PVD, PVD);
+ continue;
+ }
+ // Parameter packs should expand to a size-of-1 argument.
+ ScopeForParameters.MakeInstantiatedLocalArgPack(PVD);
+ ScopeForParameters.InstantiatedLocalPackArg(PVD, PVD);
+ }
----------------
mizvekov wrote:
I think the solution itself looks good, but I think this scope is being set up at the wrong place (pre-existing issue).
So the problem here is that when we are instantiating a function template, then we will have instantiated it's parameters, and these will be in the local scope, so when we perform constraint checking, we find them, and all is good.
But when we are doing the initial template parsing, and we need to perform this constraint checking, then there is no local instantiation scope for these parameters.
So I think this is a parsing problem and this ScopeForParameters setup should be moved there.
Since this is pre-existing, I am not opposed to doing this in a follow-up patch.
https://github.com/llvm/llvm-project/pull/102131
More information about the cfe-commits
mailing list