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

Caroline Newcombe via flang-commits flang-commits at lists.llvm.org
Mon Apr 6 08:27:02 PDT 2026


================
@@ -900,6 +900,15 @@ class UnparseVisitor {
   void Unparse(const Expr::OR &x) { Walk(x.t, ".OR."); }
   void Unparse(const Expr::EQV &x) { Walk(x.t, ".EQV."); }
   void Unparse(const Expr::NEQV &x) { Walk(x.t, ".NEQV."); }
+  void Unparse(const ConditionalExpr &x) { // F2023 R1002
+    Put("( ");
+    Walk(std::get<0>(x.t)); // scalar-logical-expr
+    Put(" ? ");
+    Walk(std::get<1>(x.t)); // then-expr
+    Put(" : ");
+    Walk(std::get<2>(x.t)); // else-expr (recursive for chained conditionals)
----------------
cenewcombe wrote:

I have added a comment explaining that extra parentheses are produced for chained conditional expressions.

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


More information about the flang-commits mailing list