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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 27 08:40:32 PDT 2023


================
@@ -402,6 +402,19 @@ 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.
----------------
AaronBallman wrote:

```suggestion
  // CollectUnexpandedParameterPacksVisitor does not expect to see a FunctionParmPackExpr, but
  // diagnosing unexpected parameter packs may still see such an expression in a lambda body. We'll
  // bail out early in this case to avoid triggering an assertion.
```
Slight rewording.

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


More information about the cfe-commits mailing list