https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119948

--- Comment #18 from kargls at comcast dot net ---
On 5/2/25 01:06, pault at gcc dot gnu.org wrote:

> I got to thinking for once. I think that your change to primary.cc has cast 
> the
> net a bit too wide and risks turning other kinds of interfaces into variables.
> How about the more specific:
> 
> diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
> index 161d4c26964..85539612504 100644
> --- a/gcc/fortran/primary.cc
> +++ b/gcc/fortran/primary.cc
> @@ -4391,7 +4391,7 @@ match_variable (gfc_expr **result, int equiv_flag, int
> host_flag)
>       case FL_PROCEDURE:
>         /* Check for a nonrecursive function result variable.  */
>         if (sym->attr.function
> -         && !sym->attr.external
> +         && (!sym->attr.external || sym->abr_modproc_decl)
>            && sym->result == sym
>            && (gfc_is_function_return_value (sym, gfc_current_ns)
>                || (sym->attr.entry
> 
> which does the right thing and regtests OK?

I must admit that I have not unraveled the logic in the if-stmt.
The comment mentions nonrecursive, yet I see no test involving
sym->attr.recursive.  At one time, a recursive procedure needed
to have an explicit interface with the RECURSIVE prefix, so the
!sym->attr.external would seem to be the test.  However, F2018
has changed Fortran where

   Procedures that are not declared with an asterisk type-param-value,
   including ELEMENTAL procedures, can be invoked recursively by default;
   the RECURSIVE keyword is advisory only.  The NON_RECURSIVE keyword
   specifies that a procedure is not recursive.

That said, your change is fine with me.

Reply via email to