[flang-commits] [PATCH] D150719: [flang] Non-type-bound defined IO lowering

vdonaldson via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue May 16 13:42:51 PDT 2023


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

Generate supporting data structures and calls to new runtime IO functions
for defined IO that accesses non-type-bound procedures, such as `wft` in:

  module m1
    type t
      integer n
    end type
    interface write(formatted)
      module procedure wft
    end interface
   contains
    subroutine wft(dtv, unit, iotype, v_list, iostat, iomsg)
      class(t), intent(in) :: dtv
      integer, intent(in) :: unit
      character(*), intent(in) :: iotype
      integer, intent(in) :: v_list(:)
      integer, intent(out) :: iostat
      character(*), intent(inout) :: iomsg
      iostat = 0
      write(unit,*,iostat=iostat,iomsg=iomsg) 'wft was called: ', dtv%n
    end subroutine
  end module
  
  module m2
   contains
    subroutine test1
      use m1
      print *, 'test1, should call wft: ', t(1)
    end subroutine
    subroutine test2
      use m1, only: t
      print *, 'test2, should not call wft: ', t(2)
    end subroutine
  end module
  
  use m1
  use m2
  call test1
  call test2
  print *, 'main, should call wft: ', t(3)
  end


https://reviews.llvm.org/D150719

Files:
  flang/include/flang/Lower/AbstractConverter.h
  flang/include/flang/Lower/Mangler.h
  flang/include/flang/Optimizer/Support/InternalNames.h
  flang/include/flang/Semantics/runtime-type-info.h
  flang/lib/Lower/Bridge.cpp
  flang/lib/Lower/IO.cpp
  flang/lib/Lower/Mangler.cpp
  flang/lib/Optimizer/Support/InternalNames.cpp
  flang/lib/Semantics/runtime-type-info.cpp
  flang/runtime/namelist.cpp
  flang/runtime/non-tbp-dio.h
  flang/test/Lower/derived-type-finalization.f90
  flang/test/Lower/io-derived-type.f90
  flang/test/Lower/namelist.f90
  flang/test/Lower/parent-component.f90
  flang/test/Lower/vector-subscript-io.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150719.522768.patch
Type: text/x-patch
Size: 69046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230516/4a2cb480/attachment-0001.bin>


More information about the flang-commits mailing list