[flang-commits] [flang] [flang] Update PUBLIC and PRIVATE accessibility to Fortran 2018 (PR #177596)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Tue Jan 27 05:22:34 PST 2026


================
@@ -9575,6 +9589,41 @@ bool ModuleVisitor::Pre(const parser::AccessStmt &x) {
     for (const auto &accessId : accessIds) {
       GenericSpecInfo info{accessId.v.value()};
       auto *symbol{FindInScope(info.symbolName())};
+      // An access-spec may have an access-name (module) in order to set
+      // the default accessibility for everything USE-associated from
+      // that module. The module name won't be in the current scope,
+      // so we need to check the global scope.
+      if (info.kind().IsName()) {
+        const Symbol *moduleSymbol{nullptr};
+        Symbol *resolveSymbol{nullptr};
+        if (symbol) {
+          // Check if symbol in current scope is USE-associated from a module
----------------
eugeneepshteyn wrote:

Would this handle the following 3-level module use:
```
module A
  integer :: x = 1
end module A

module B
  use A
  public :: x ! Re-export x
end module B

module C
  use B
  implicit none
  private
  public :: B
end module C

program main
  use C
  implicit none
  print *, x
end program
```
(This program works with ifx.)

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


More information about the flang-commits mailing list