Hi Yuao, That's exactly how I had a mind to do it. You beat me to it :-(
Just get on, polish the patch and add more tests. Thanks Paul On Wed, 30 Jul 2025 at 15:53, Yuao Ma <c...@outlook.com> wrote: > Hi all, > > This patch introduces support for conditional expressions (also known as > ternary operators in some languages) to Fortran. I decided to implement > this feature after discovering that this common functionality, widely > used in C/C++, wasn't available until the Fortran 2023 standard. This > was also a great opportunity to learn more about gfortran's internals, > as it required touching both the front-end and back-end. > > For the front-end, I manually parsed the right-associative conditional > expression, which required some special logic. On the back-end, I simply > forwarded it to COND_EXPR. I also added support for tools like the > parse-tree dump. > > I'm not sure if we need to handle constant folding ourselves, or if > COND_EXPR will take care of it. > > I plan to add more tests and polish the patch. However, I want to get > some early feedback on the general approach. Please take a look when you > have a moment. > > Thanks in advance, > Yuao