[Bug fortran/123321] Namelist input of variable accessed by use association with renaming fails
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Dec 27 21:51:54 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123321
--- Comment #5 from Steve Kargl <kargl at gcc dot gnu.org> ---
(In reply to Steve Kargl from comment #3)
> This diff
>
> diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
> index 9360bddb30a..bbcfc292c0a 100644
> --- a/gcc/fortran/trans-io.cc
> +++ b/gcc/fortran/trans-io.cc
> @@ -1698,7 +1698,7 @@ transfer_namelist_element (stmtblock_t * block, const
> char * var_name,
> gcc_assert (sym || c);
>
So, the patch causes a testsuite regression with
gfortran.dg/namelist_use_only.f90. I think that
test may be wrong, but I'm not a namelist user.
It has (removing unimportant code)
module global
character*4 :: aaa
integer :: iii
real :: rrr
namelist /nml2/ aaa, iii, rrr
end module global
program namelist_use_only
use global, only : nml2, rrrr=>rrr
open (10, status="scratch")
write (10,'(a)') "&NML2 aaa='pqrs' iii=2 rrr=3.5 /"
rewind (10)
read (10,nml=nml2,iostat=i)
if ((i.ne.0).or.(rrrr.ne.3.5)) STOP 2
close (10)
end program namelist_use_only
The renaming of 'rrrr=>rrr' means 'rrr' from the module
is unavailable in the program unit. The read statement with
'nml=nml2' uses a namelist defined in terms of 'rrr'. This
seems to be an interesting way to access an entity from a
module that has been renamed.
More information about the Gcc-bugs
mailing list