================
@@ -77,11 +77,13 @@ inline std::optional<std::pair<unsigned, unsigned>>
 getDepthAndIndex(UnexpandedParameterPack UPP) {
   if (const auto *TTP = dyn_cast<const TemplateTypeParmType *>(UPP.first))
     return std::make_pair(TTP->getDepth(), TTP->getIndex());
-  if (isa<NamedDecl *>(UPP.first))
-    return getDepthAndIndex(cast<NamedDecl *>(UPP.first));
-  assert((isa<const TemplateSpecializationType *,
-              const SubstBuiltinTemplatePackType *>(UPP.first)));
-  return std::nullopt;
+  if (isa<const TemplateSpecializationType *,
+          const SubstBuiltinTemplatePackType *>(UPP.first))
+    return std::nullopt;
+  const auto *ND = cast<NamedDecl *>(UPP.first);
+  if (isa<ParmVarDecl>(ND))
+    return std::nullopt;
----------------
zwuis wrote:

`addPacks` collects packs **we are deducing** (I just update the PR 
description). Function parameter packs cannot be deduced, so we just ignore 
them.

> ... A ParmVarDecl could refer to a template parameter pack, no?

Yes, but the template parameter pack is not affected, it is still collected.

```cpp
template <typename ...Ts>
void f(Ts ...args1, decltype(args1) ...args2);
```

When performing deduction on `args1`,  `addPacks` collects `Ts` from the type 
of `args1` (`Ts`). (Not sure if `Ts` can be deduced though. Just an example.)

When performing deduction on `args2`, `addPacks` collects `args1` from the type 
of `args2` (`decltype(args1)`), then `args1` is ignored.

https://github.com/llvm/llvm-project/pull/215235
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to