[clang] [clang][Sema] Handle function parameter packs in `PackDeductionScope::addPacks` (PR #215235)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 21:00:21 PDT 2026


================
@@ -935,6 +935,11 @@ class PackDeductionScope {
       S.collectUnexpandedParameterPacks(Pattern, Unexpanded);
       for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
         unsigned Depth, Index;
+
+        // Function parameter packs cannot be deduced.
+        if (isa_and_nonnull<ParmVarDecl>(
+                dyn_cast<NamedDecl *>(Unexpanded[I].first)))
+          continue;
----------------
zyn0217 wrote:

```suggestion
        // We could never deduce packs from an unexpanded parameter.
        if (isa_and_present<ParmVarDecl>(
                dyn_cast<NamedDecl *>(Unexpanded[I].first)))
          continue;
```

`// Function parameter packs cannot be deduced.`: This is confusing, for example

```cpp
void f(auto... param) {
  auto g = [](decltype(param)... pp) {};
  g(param...);
}
```

in such context, `pp` are indeed deduced from (though substituted) `param...`.

https://github.com/llvm/llvm-project/pull/215235


More information about the cfe-commits mailing list