71 lines · plain
1! Check that InputDerivedType/OutputDeriverType APIs are used2! for io of derived types.3! RUN: bbc -emit-fir -o - %s | FileCheck %s4 5module p6 type :: person7 type(person), pointer :: next => null()8 end type person9 type :: club10 class(person), allocatable :: membership(:)11 end type club12contains13 subroutine pwf (dtv,unit,iotype,vlist,iostat,iomsg)14 class(person), intent(in) :: dtv15 integer, intent(in) :: unit16 character (len=*), intent(in) :: iotype17 integer, intent(in) :: vlist(:)18 integer, intent(out) :: iostat19 character (len=*), intent(inout) :: iomsg20 print *, 'write'21 end subroutine pwf22 subroutine prf (dtv,unit,iotype,vlist,iostat,iomsg)23 class(person), intent(inout) :: dtv24 integer, intent(in) :: unit25 character (len=*), intent(in) :: iotype26 integer, intent(in) :: vlist(:)27 integer, intent(out) :: iostat28 character (len=*), intent(inout) :: iomsg29 end subroutine prf30 subroutine test1(dtv)31 interface read(formatted)32 module procedure prf33 end interface read(formatted)34 class(person), intent(inout) :: dtv35 read(7, fmt='(DT)') dtv%next36 end subroutine test137! CHECK-LABEL: func.func @_QMpPtest1(38! CHECK: %{{.*}} = fir.call @_FortranAioInputDerivedType(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>, !fir.ref<none>) -> i139 40 subroutine test2(social_club)41 interface read(formatted)42 module procedure prf43 end interface read(formatted)44 class(club) :: social_club45 read(7, fmt='(DT)') social_club%membership(0)46 end subroutine test247! CHECK-LABEL: func.func @_QMpPtest2(48! CHECK: %{{.*}} = fir.call @_FortranAioInputDerivedType(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>, !fir.ref<none>) -> i149 50 subroutine test3(dtv)51 interface write(formatted)52 module procedure pwf53 end interface write(formatted)54 class(person), intent(inout) :: dtv55 write(7, fmt='(DT)') dtv%next56 end subroutine test357! CHECK-LABEL: func.func @_QMpPtest3(58! CHECK: %{{.*}} = fir.call @_FortranAioOutputDerivedType(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>, !fir.ref<none>) -> i159 60 subroutine test4(social_club)61 interface write(formatted)62 module procedure pwf63 end interface write(formatted)64 class(club) :: social_club65 write(7, fmt='(DT)') social_club%membership(0)66 end subroutine test467! CHECK-LABEL: func.func @_QMpPtest4(68! CHECK: %{{.*}} = fir.call @_FortranAioOutputDerivedType(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>, !fir.ref<none>) -> i169end module p70 71