Fortran · 1059 bytes Raw Blame History
1 ! audit31 Finding 17: a submodule providing the implementation of a
2 ! parent module's separate-module function parsed cleanly but emitted
3 ! no IR, so the linker reported `Undefined symbols: _compute`. The
4 ! lowerer's lower_unit only matched ProgramUnit::Module — Submodule
5 ! fell through the catch-all `_ => {}` arm and produced no body.
6 ! Fix: extend lower_unit and the supporting collect_* / host-ref
7 ! walkers to descend into Submodule contains, and register the
8 ! submodule's own decls as globals under the parent module's name so
9 ! its contained procedures can resolve them via the same global
10 ! lookup. Task #498.
11 ! CHECK: 50
12 module base
13 implicit none
14 interface
15 module function compute(x) result(r)
16 integer, intent(in) :: x
17 integer :: r
18 end function
19 end interface
20 end module
21
22 submodule (base) impl
23 contains
24 module function compute(x) result(r)
25 integer, intent(in) :: x
26 integer :: r
27 r = x * 10
28 end function
29 end submodule
30
31 program audit31_submodule
32 use base
33 implicit none
34 print *, compute(5)
35 end program
36