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

--- Comment #2 from Steve Kargl <kargl at gcc dot gnu.org> ---
This is going to be fun.

  Fortran 2023:19.2

  Program units, common blocks, external procedures, entities with
  binding labels, external input/output units, pending data transfer
  operations, and images are global entities of a program.

  19.5.1.4 Host association
  ...
  A name that appears in the scoping unit as
    (1) a function-name in a stmt-function-stmt or in an entity-decl
        in a type-declaration-stmt, unless it is a global identifier,
    ...
    (14) an intrinsic-procedure-name in an intrinsic-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, if I understand the above correctly(, which is always a challenge).


   program foo
   real, external :: bar   ! bar is a global identifier via 19.2
   print *, bar(1.)
   call sub
   contains
      subroutine sub
         import, none      ! should not block bar()
         print *, bar(2.)  
      end subroutine sub
   end program foo

   function bar(a)
   real bar
   real, intent(in) :: a
   bar = a
   end function bar

Furthermore, we have

   program foo
   intrinsic :: sin    ! sin is a a generic name so (14) 
   print *, sin(1.d0)  ! does not apply.
   call sub
   contains
      subroutine sub
         import, none
         print *, sin(2.d0)  ! sin is accessible
      end subroutine sub
   end program foo

but

   program foo
   intrinsic :: dsin    ! dsin is a a specific name so (14) 
   print *, dsin(1.d0)  ! applies, and is a local identifier.
   call sub
   contains
      subroutine sub
         import, none
         print *, dsin(2.d0)  ! dsin is inaccessible
      end subroutine sub
   end program foo

Reply via email to