[flang-commits] [flang] [flang] A module that USEs itself directly in its specification part … (PR #228489)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Mon Oct 19 08:57:45 PDT 2026
================
@@ -4916,7 +4916,8 @@ Scope *ModuleVisitor::FindModule(const parser::Name &name,
Scope *scope{
reader.Read(name.source, isIntrinsic, ancestor, /*silent=*/false)};
if (scope) {
- if (DoesScopeContain(scope, currScope())) { // 14.2.2(1)
+ if (DoesScopeContain(scope, currScope()) ||
+ scope->Contains(currScope())) { // 14.2.2(1)
----------------
eugeneepshteyn wrote:
(This comment was generated with the help of AI)
The second reproducer in issue 227340 still gets the misleading message the issue describes, now in addition to the new error:
```fortran
module m1
use m1, only: y
integer :: y = 1
end module m1
```
```console
$ flang -fsyntax-only repro2.f90
error: Semantic errors in repro2.f90
repro2.f90:2:7: error: Module 'm1' cannot USE itself
use m1, only: y
^^
repro2.f90:2:17: error: 'y' not found in module 'm1'
use m1, only: y
^
```
I'd suggest suppressing only the "'%s' not found in module '%s'" error in `ModuleVisitor::AddUse` when `useModuleScope_` contains the current scope, because that USE has already been reported here.
https://github.com/llvm/llvm-project/pull/228489
More information about the flang-commits
mailing list