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

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 23 06:52:08 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())
----------------
zyn0217 wrote:

Thanks, I almost forget it ;)

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


More information about the cfe-commits mailing list