[clang] [clang][Sema] Avoid non-empty unexpanded pack assertion for FunctionParmPackExpr (PR #69224)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 23 05:10:58 PDT 2023


================
@@ -402,6 +402,20 @@ bool Sema::DiagnoseUnexpandedParameterPack(Expr *E,
   if (!E->containsUnexpandedParameterPack())
     return false;
 
+  // Exception: The `CollectUnexpandedParameterPacksVisitor` collects nothing
+  // from a FunctionParmPackExpr. In the context where the collector is being
+  // used such as `collectUnexpandedParameterPacks`, this type of expression
+  // is not expected to be collected.
+  //
+  // Nonetheless, this function for diagnosis is still called anyway during
+  // template instantiation, with an expression of such a type if we're inside a
+  // lambda with unexpanded parameters.
+  //
+  // Rule out this case to prevent the assertion failure.
+  if (auto *Expr = dyn_cast<FunctionParmPackExpr>(E);
+      Expr && getEnclosingLambda())
----------------
tbaederr wrote:

```suggestion
  if (isa<FunctionParmPackExpr>(E) && getEnclosingLambda())
```

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


More information about the cfe-commits mailing list