[clang] [flang] [llvm] [flang] Diagnose and optionally repair missing MODULE procedure prefixes (PR #220783)

Eugene Epshteyn via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 07:28:12 PDT 2026


================
@@ -595,6 +595,14 @@ end program
   [-fimplicit-none-type-always]
 * Ignore occurrences of `IMPLICIT NONE` and `IMPLICIT NONE(TYPE)`
   [-fimplicit-none-type-never]
+* Treat a subprogram in a submodule as if it had a missing `MODULE` prefix
+  when its name matches a separate module procedure interface in an ancestor
+  module [-fimplicit-module-prefix]. This extension is disabled by default
+  because the unprefixed subprogram can instead be a conforming local
+  procedure. Without this extension, `-pedantic` or `-Wportability` diagnoses
+  a likely missing prefix without changing the program. When the extension
+  is enabled, `-Wimplicit-module-prefix` or `-pedantic` reports each repaired
+  prefix.
----------------
eugeneepshteyn wrote:

It's worth documenting that, like gfortran, this option rejects a conforming program in which a submodule keeps a local helper with the same name as an ancestor's separate module procedure that is implemented elsewhere:

```fortran
module m
  interface
    module subroutine helper
    end subroutine
  end interface
end module

submodule(m) sm1
contains
  subroutine helper ! local to sm1
  end subroutine
end submodule

submodule(m) sm2
contains
  module subroutine helper
  end subroutine
end submodule
```

`flang -fsyntax-only` accepts this. With `-fimplicit-module-prefix` it reports `Module procedure 'helper' in 'm' has multiple definitions`. `implicit-module-prefix-shadow.f90` has exactly this shape but runs only without the option; a `not %flang_fc1 -fimplicit-module-prefix` RUN line there would pin the behavior.


https://github.com/llvm/llvm-project/pull/220783


More information about the llvm-commits mailing list