[clang] [Clang] Handle ?: operator in fold expression (PR #164019)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 13 08:14:17 PDT 2026
cor3ntin wrote:
@azmat-y I spent some time looking into this. because `?:` is never valid in a fold expression, we parse it as a conditional expression - so far so good. but we never check that the expressions involve don't contain packs.
So a proper fix would be something like:
```diff
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9200,6 +9200,12 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
SourceLocation ColonLoc,
Expr *CondExpr, Expr *LHSExpr,
Expr *RHSExpr) {
+
+ if(DiagnoseUnexpandedParameterPack(CondExpr) ||
+ (LHSExpr && DiagnoseUnexpandedParameterPack(LHSExpr))
+ || DiagnoseUnexpandedParameterPack(RHSExpr))
+ return ExprError();
+
```
Can you modify your patch? thanks!
https://github.com/llvm/llvm-project/pull/164019
More information about the cfe-commits
mailing list