Help with module.c and free_pi_tree()

mikael.morin@sfr.fr mikael.morin@sfr.fr
Sat Dec 14 13:25:00 GMT 2013


Hello,

symbol names clashes are OK: they are the original names, and not necessarily the names under which the symbols are accessible (think of use renaming).
As for the symtree names, it depends: they are the ones used for symbol lookup so there shouldn't be clashes.
However duplicate names are possible as long as the symbol is not referenced.

for example this is allowed since "i" is not refered to in baz:

module foo
    integer :: i
end module foo

module bar
    integer :: i
end module bar

module baz
   use foo
   use bar
end module bar


Pay attention to the fact that symtrees are local to namespaces (modules, procedures, etc).
Also pay attention to the fact that for derived types there is a capital initial letter implementation detail to support constructors with the same name as types: inside the compiler, "type" is different from "Type".


I _think_ that the ICE is indeed related to name clashes, because name clashes can change the behaviour of gfc_use_module: a symbol from a module is not loaded again if it is already present in the current namespace. 
For example,

module foo
   integer ::i
end module foo

module bar
   use foo
end module bar

module baz1
   use foo
   use bar
end module baz1

module baz2
   use bar
   use foo
end module baz2

In this example "i" won't be loaded again for "use bar" in "baz1" and for "use foo" in "baz2".

Now if something in "bar" uses "bar::i" (which is actually "foo::i") there is no problem in baz2, but in baz1, as "bar::i" is not loaded, references to it should be redirected to "foo::i" which is present in the namespace.
I'm pretty sure it works in the simple cases, but obviously not always. I haven't been able to point the problem exactly though.

Mikael

PS: disclaimer: the above has been written from recollection, without looking at the most up-to-date code. Beware ;-)



More information about the Fortran mailing list