Fortran: fix ICE with use with rename of namelist member [PR116530]
gcc/fortran/ChangeLog: PR fortran/116530 * trans-io.cc (transfer_namelist_element): Prevent NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/116530 * gfortran.dg/use_rename_12.f90: New test.
This commit is contained in:
parent
81c47986e1
commit
6bfeba12c8
2 changed files with 29 additions and 1 deletions
|
@ -1692,7 +1692,8 @@ transfer_namelist_element (stmtblock_t * block, const char * var_name,
|
|||
gcc_assert (sym || c);
|
||||
|
||||
/* Build the namelist object name. */
|
||||
if (sym && !sym->attr.use_only && sym->attr.use_rename)
|
||||
if (sym && !sym->attr.use_only && sym->attr.use_rename
|
||||
&& sym->ns->use_stmts->rename)
|
||||
string = gfc_build_cstring_const (sym->ns->use_stmts->rename->local_name);
|
||||
else
|
||||
string = gfc_build_cstring_const (var_name);
|
||||
|
|
27
gcc/testsuite/gfortran.dg/use_rename_12.f90
Normal file
27
gcc/testsuite/gfortran.dg/use_rename_12.f90
Normal file
|
@ -0,0 +1,27 @@
|
|||
! { dg-do compile }
|
||||
! PR fortran/116530 - ICE with member of namelist renamed by use module
|
||||
!
|
||||
! Reported by philippe.wautelet at cnrs.fr
|
||||
|
||||
module mod_nml1
|
||||
implicit none
|
||||
logical :: ldiag
|
||||
namelist /nam_nml1/ldiag
|
||||
end module mod_nml1
|
||||
|
||||
module mod_interm
|
||||
use mod_nml1
|
||||
end module mod_interm
|
||||
|
||||
program ice_nml
|
||||
use mod_nml1, ldiag_nml1 => ldiag
|
||||
use mod_nml1, only : ldiag_only => ldiag
|
||||
use mod_interm
|
||||
implicit none
|
||||
integer :: ilu = 10
|
||||
read(unit=ilu,nml=nam_nml1)
|
||||
write(unit=*,nml=nam_nml1)
|
||||
print *, ldiag
|
||||
print *, ldiag_nml1
|
||||
print *, ldiag_only
|
||||
end program ice_nml
|
Loading…
Add table
Reference in a new issue