[flang] Warn when a submodule subprogram hides a like-named external-interface body from its parent module
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
PR #197173 added a portability warning for a submodule subprogram that is
missing the `MODULE` prefix required to implement a *separate module procedure*
interface from its parent. That PR was deliberately scoped to separate module
procedure interfaces. The scenario originally reported in #197171 uses a plain
(non-`MODULE`) interface body — so although #197171 is now closed, this shape
still produces no diagnostic:
```fortran
module m
interface
subroutine inside_one()
end subroutine
end interface
end module
submodule (m) s
contains
subroutine inside_one()
end subroutine
end submodule
```
```console
$ flang -fsyntax-only -pedantic t.f90 # upstream main 62b7ae5dc327
$ # no diagnostic
```
Here the submodule's `inside_one` is an ordinary submodule-local subprogram
that hides the external interface; it neither implements the interface nor is
callable from outside. A diagnostic would be useful, but it needs different
wording than #197173's: suggesting a `MODULE` prefix is wrong for this shape —
following it is a hard error, since `inside_one` was not declared a separate
module procedure:
```console
$ flang -fsyntax-only -pedantic t-with-module-prefix.f90 # same, with MODULE prefix added
error: 'inside_one' was not declared a separate module procedure
```
Something like "Subprogram 'x' in this submodule hides the external interface
'x' from its parent module and cannot implement it" would fit.
Contributor guide
Research direction
Reproduce the missing diagnostic with t.f90 using `flang -fsyntax-only -pedantic`, then compare it with t-with-module-prefix.f90 and its existing error. Trace the handling of submodule-local subprograms and external interfaces; done means the plain-interface case emits a warning with wording that does not suggest adding `MODULE`.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100