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

Steve Kargl <kargl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #63173|0                           |1
        is obsolete|                            |

--- Comment #18 from Steve Kargl <kargl at gcc dot gnu.org> ---
Created attachment 63193
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63193&action=edit
Patch and new testcase

The attached patch and testcase pass regression testing on FreeBSD.
I'll note that bootstrap is currently broken on FreeBSD, so the 
patch was developed against circa 12-10-26 sources.  I believe this
fixed Van's issue.

Now, there is one wrinkle and gfortran already ready violates
what I believe the standard intends.  Fortran 2023, page 132 has

  A namelist group object shall either be accessed by use or host
  association or ...

consider,

  module m
    implicit none
    private
    public tol, z
    integer :: tol = 42
    integer :: z = 42
  end module m

  subroutine only_clause_with_renaming
    !
    ! Renaming means 'tol' is inaccessible from via
    ! USE associate (by the name 'tol').
    !
    use m, only: y => tol, z
    implicit none
    character(len=20) :: str = "&v z=1 y=1/"
    real :: tol = 0
    !
    ! Here, the patch accepts the namelist with the object 'y'
    ! but the backing storage is that of 'tol'.  The REAL 
    ! 'tol' shows that 'tol' from the module is not accessed by
    ! that name.
    !
    namelist /v/ y, z
    read(str, nml=v)
    if (z /= 1) stop 3
    if (y /= 1) stop 4
    if (tol /= 0) stop 5
  end subroutine only_clause_with_renaming

  program p
    use m
    print '(I0,1x,I0)', tol, z
    call only_clause_with_renaming
    !
    ! After the call to 'only_clause_with_renaming', the
    ! value of 'tol' has magically been updated from 42
    ! to 1.  Is this surprising?  Is this a violation of
    ! the above standardese.
    !
    print '(I0,1x,I0)', tol, z
  end program p

Reply via email to