[flang-commits] [PATCH] D158038: [flang] Separate module procedure variant

vdonaldson via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Aug 15 16:36:18 PDT 2023


vdonaldson created this revision.
vdonaldson added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a project: All.
vdonaldson requested review of this revision.

Accept "module procedure" (as well as module function/subroutine)
in a separate module procedure definition, such as "bb1" in:

  module mm
    interface
      module subroutine mm1
      end subroutine
    end interface
  end module
  
  submodule(mm) bb
    interface
      module subroutine bb1
      end subroutine
    end interface
  contains
    module procedure mm1
      call bb1
    end procedure
    module procedure bb1
      print*, 'bb1'
    end procedure
  end submodule
  
    use mm
    call mm1
  end


https://reviews.llvm.org/D158038

Files:
  flang/lib/Lower/Mangler.cpp


Index: flang/lib/Lower/Mangler.cpp
===================================================================
--- flang/lib/Lower/Mangler.cpp
+++ flang/lib/Lower/Mangler.cpp
@@ -136,9 +136,8 @@
             if (interface->attrs().test(Fortran::semantics::Attr::MODULE) &&
                 interface->owner().IsSubmodule() && !subpDetails.isInterface())
               interface = subpDetails.moduleInterface();
-            assert(interface && "Separate module procedure must be declared");
-            std::tie(modules, procs, blockId) =
-                ancestors(*interface, scopeBlockIdMap);
+            std::tie(modules, procs, blockId) = ancestors(
+                interface ? *interface : ultimateSymbol, scopeBlockIdMap);
             return fir::NameUniquer::doProcedure(modules, procs, symbolName);
           },
           [&](const Fortran::semantics::ProcEntityDetails &) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158038.550536.patch
Type: text/x-patch
Size: 883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230815/a6af01de/attachment.bin>


More information about the flang-commits mailing list