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

25 lines
342 B
Fortran

!RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s --allow-empty
!CHECK-NOT: error:
module m1
interface
module subroutine foo
end
end interface
real x
end
module m2
use m1
end
submodule(m1) sm1
use m2 ! ok
contains
module procedure foo
end
end
submodule(m1) sm2
contains
subroutine bar
use m2 ! ok
end
end