Skip to content

Fortran: identical symbols defined in both modules and submodules are not merged into one #1803

Description

@sgeard

Summary

For Fortran code that uses the standard module/submodule separation — interface
declared in a module, implementation in a submodule, each in its own file —
the extractor creates two nodes for the same procedure (one per file) with
no edge of any kind between them. The submodule (parent) name header is
not recognised, so the parent–child relationship between the two files is
completely absent from the graph, and the duplicate nodes cannot be merged
even in principle.

Since node ids are file-scoped, the same applies to use-association: every
file that uses a module (including intrinsics like iso_fortran_env) mints
a fresh per-file node instead of resolving to the defining node.

Reproducer

Two files (compile cleanly with gfortran -c sym_ex.f90 sym_ex_sm.f90):

sym_ex.f90 — the module, declaring the interface:

module sym_ex
        implicit none
        interface
                pure module function add_e(a,b) result(r)
                        real(8), intent(in) :: a, b
                        real(8) :: r
                end function add_e
        end interface
end module sym_ex

sym_ex_sm.f90 — the submodule, providing the implementation:

submodule (sym_ex) sym_ex_sm
        implicit none
contains
        pure module function add_e(a,b) result(r)
                real(8), intent(in) :: a, b
                real(8) :: r
                r = a + b
        end function add_e
end submodule sym_ex_sm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions