llvm-project/flang/test/Semantics/separate-mp04.f90
Peter Klausler 77e965ef45
[flang] Allow for submodule override of module procedure
When checking that a module procedure definition is unique, allow for
the possibility that a submodule may contain a module procedure
interface that shadows a module procedure of the same name in its
(sub)module parent.   In other words, module procedure definitions
need only be unique in the tree of submodules rooted at the (sub)module
containing the relevant module procedure interface.

Differential Revision: https://reviews.llvm.org/D159033
2023-08-29 09:00:26 -07:00

58 lines
1.1 KiB
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! Checks for multiple module procedure definitions
module m1
interface
module subroutine x001
end subroutine
module subroutine x002
end subroutine
module subroutine x003
end subroutine
end interface
end
submodule(m1) sm1
interface
module subroutine x004
end subroutine
end interface
contains
module procedure x001 ! fine
end procedure
module subroutine x002
end subroutine
module subroutine x003
end subroutine
end
submodule(m1) sm2
contains
!ERROR: Module procedure 'x002' in 'm1' has multiple definitions
module subroutine x002
end subroutine
end
submodule(m1:sm2) sm3
contains
!ERROR: Module procedure 'x002' in 'm1' has multiple definitions
module subroutine x002
end subroutine
!ERROR: Module procedure 'x003' in 'm1' has multiple definitions
module subroutine x003
end subroutine
end
submodule(m1:sm1) sm4
contains
module subroutine x004
end subroutine
end
submodule(m1:sm1) sm5
contains
!ERROR: Module procedure 'x004' in 'm1:sm1' has multiple definitions
module subroutine x004
end subroutine
end