[RFC, fortran] Output contained namespaces in module (PR fortran/16861)

Paul Thomas paulthomas2@wanadoo.fr
Fri Jul 15 17:45:00 GMT 2005


David,

A partial answer to your question, about which symbols should or should
not be written, is provided by the example below.  You are either
exposing a bug by avoiding the ICE or are causing it; I am not sure
which, yet.  It seems to me, though, that symbols that are declared in
contained functions must not be broadcast to the parent namespaces.  In
this case, J becomes ambiguous in BAZ because FOO contains BIZ, which
uses its own symbol J.

Even if J is changed to K, in BIZ, the code still does not compile
because BAZ is ambiguous from namespace BAR.  At least it does not ICE,
though!  That is progress.

The example compiles and runs correctly with ifc, by the way.

Bizarrely, you have turned the ICE in pr16940 into a, well... , enigmatic:

  In file pr16940.f90:19

   end module Max_Loc_Mod
                        1
  Internal Error at (1):
  write_symtree(): Symbol not written

which persists, even when the workaround, described in the pr, is deployed.

Paul T


module FOO
   integer :: I
contains
   subroutine BIZ(J)
     integer, dimension(I) :: J
     J = 0
   end subroutine BIZ
end module FOO

module BAR
contains
   subroutine BAZ(J)
     use FOO
     integer, dimension(I) :: J
     call BIZ (J)
     print *, J
   end subroutine BAZ
end module BAR

PROGRAM QUUS
   use FOO
   use BAR
   INTEGER    :: Z(2) = (/5,6/)
   I = 2
   call BAZ (Z)
end PROGRAM QUUS


produces, inter alia:

     integer, dimension(I) :: J
                              1
Error: Name 'j' at (1) is an ambiguous reference to 'j' from current
program unit
  In file pr16861.f90:15

     call BIZ (J)
               1
Error: Name 'j' at (1) is an ambiguous reference to 'j' from current
program unit
  In file pr16861.f90:16

     print *, J
              1
Error: Name 'j' at (1) is an ambiguous reference to 'j' from current
program unit






More information about the Fortran mailing list