Peter Klausler c82db773f4
[flang] Handle indirect USE of ancestor module into submodule (#124969)
A USE statement within a submodule (possibly in a nested scope) is not
allowed to USE the submodule's ancestor module directly, but it is
permissible to USE that ancestor module indirectly via another unrelated
module. Don't emit "already present in scope" errors for this case.

Fixes https://github.com/llvm/llvm-project/issues/124731.
2025-01-31 10:54:25 -08:00

27 lines
476 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
module m
interface
module subroutine separate
end
end interface
contains
subroutine modsub
!ERROR: Module 'm' cannot USE itself
use m
end
end
submodule(m) submod1
contains
module subroutine separate
!ERROR: Module 'm' cannot USE itself from its own submodule 'submod1'
use m
end
end
submodule(m) submod2
!ERROR: Module 'm' cannot USE itself from its own submodule 'submod2'
use m
end