[flang-commits] [flang] [flang] Implement conditional expressions parser/semantics (F2023) (PR #186489)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Mon Mar 30 20:52:34 PDT 2026


================
@@ -1736,6 +1729,18 @@ struct ArgumentExtractor
     return {operation::OperationCode(x), {AsSomeExpr(x)}};
   }
 
+  template <typename T> Result operator()(const ConditionalExpr<T> &x) const {
+    // ConditionalExpr is a top-level operation; collect its immediate operands
+    Arguments args{AsSomeExpr(x.condition()), AsSomeExpr(x.thenValue())};
+    if (const auto *nested{std::get_if<ConditionalExpr<T>>(&x.elseValue().u)}) {
----------------
eugeneepshteyn wrote:

Why is only `elseValue()` being collected with nesting? Wouldn't `thenValue()` need similar processing?

Would it be possible to rewrite this using recursion?  For example, could use `(*this)(x.elseValue())`.

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


More information about the flang-commits mailing list