[PATCH] fortran: support .NIL. in conditional arguments

Tobias Burnus tburnus@baylibre.com
Tue Nov 11 15:38:50 GMT 2025


Hi Yuao,

Yuao Ma wrote:
> Looking at my attached patch, I immediately found 2 bugs:
> 1. A typo that changes rse to lse.
> 2. In conv_dummy_value, in addition to handling the optionalarg, we
> also need to handle se->expr.
> After fixing these two issues, some of the cond-expr-1 tests now work.
> However, cond-expr-2 is experiencing some segfaults.

I still need to find the time to look more closely at your patch.

However, I can already add two other items:

> gcc/fortran/ChangeLog:
>
> 	* trans-expr.cc (gfc_conv_missing_dummy):
> 	(conv_dummy_value):
> 	(gfc_conv_procedure_call):

This still needs to be filled.

and

Your patch fails to bootstrap (which implies -Werror for stage 2 + 3):

gcc/fortran/trans-expr.cc:8062:17: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
  8061 |           if (e->expr_type == EXPR_VARIABLE && e->symtree->n.sym->attr.optional
  8062 |                 && (((e->rank != 0 && elemental_proc)
...
  8070 |                                      || fsym->as->type == AS_DEFERRED)))))
  8071 |                     || se->ignore_optional)
  8072 |               || e->expr_type == EXPR_CONDITIONAL)

* * *

> Note that even without cond-expr, the current trunk still has bugs
> related to dummy value/reference, dating back to gfortran 14:
> https://godbolt.org/z/3aGM6enjv. I will work on fixing this.

Thanks for looking into that issue – if needed, we can bisect, but just 
fixing it might be easier.

* * *

> By the way, could you please update the status of
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122342? I believe it is
> now resolved.

I concur. BTW: you could try to get a Bugzilla account at 
https://gcc.gnu.org/bugzilla/createaccount.cgi using the 
<login>@gcc.gnu.org mail address.

Tobias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/fortran/attachments/20251111/703d27e9/attachment.htm>


More information about the Fortran mailing list