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

--- Comment #4 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #3)
> The code is invalid.  Patch against svn revision 280156.
> 
> Index: gcc/fortran/module.c
> ===================================================================
> --- gcc/fortran/module.c      (revision 280157)
> +++ gcc/fortran/module.c      (working copy)
> @@ -5738,7 +5738,11 @@ write_symbol (int n, gfc_symbol *sym)
>    const char *label;
>  
>    if (sym->attr.flavor == FL_UNKNOWN || sym->attr.flavor == FL_LABEL)
> -    gfc_internal_error ("write_symbol(): bad module symbol %qs", sym->name);
> +    {
> +      gfc_error ("Invalid symbol %qs at %L", sym->name,
> +              &sym->declared_at);
> +      return;
> +    }
>  
>    mio_integer (&n);

The patch is wrong and Gerhard is sort of correct.  z1.f90 is
invalid as the result variable is never set.  But, an internal
error should not be signaled.  Fortran 2018 has

  19.5.1.4 Host association

  A name that appears in the scoping unit as
  ...
    (12) a result-name in a function-stmt or in an entry-stmt,
  ...
  is a local identifier in the scoping unit and any entity of the host
  that has this as its nongeneric name is inaccessible by that name by
  host association.

So, the type 't' is inaccessible in the local scope of f().  The code
is a good example for the requirement of 'implicit none'.

Reply via email to