IR: de-duplicate two CmpInst routines (NFC) (#116866)
[llvm-project.git] / flang / test / Lower / io-derived-type-2.f90
blobeeea2ae156f945ca9a7f552b990ca3c22c62e80a
1 ! Check that InputDerivedType/OutputDeriverType APIs are used
2 ! for io of derived types.
3 ! RUN: bbc -emit-fir -o - %s | FileCheck %s
5 module p
6 type :: person
7 type(person), pointer :: next => null()
8 end type person
9 type :: club
10 class(person), allocatable :: membership(:)
11 end type club
12 contains
13 subroutine pwf (dtv,unit,iotype,vlist,iostat,iomsg)
14 class(person), intent(in) :: dtv
15 integer, intent(in) :: unit
16 character (len=*), intent(in) :: iotype
17 integer, intent(in) :: vlist(:)
18 integer, intent(out) :: iostat
19 character (len=*), intent(inout) :: iomsg
20 print *, 'write'
21 end subroutine pwf
22 subroutine prf (dtv,unit,iotype,vlist,iostat,iomsg)
23 class(person), intent(inout) :: dtv
24 integer, intent(in) :: unit
25 character (len=*), intent(in) :: iotype
26 integer, intent(in) :: vlist(:)
27 integer, intent(out) :: iostat
28 character (len=*), intent(inout) :: iomsg
29 end subroutine prf
30 subroutine test1(dtv)
31 interface read(formatted)
32 module procedure prf
33 end interface read(formatted)
34 class(person), intent(inout) :: dtv
35 read(7, fmt='(DT)') dtv%next
36 end subroutine test1
37 ! CHECK-LABEL: func.func @_QMpPtest1(
38 ! CHECK: %{{.*}} = fir.call @_FortranAioInputDerivedType(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>, !fir.ref<none>) -> i1
40 subroutine test2(social_club)
41 interface read(formatted)
42 module procedure prf
43 end interface read(formatted)
44 class(club) :: social_club
45 read(7, fmt='(DT)') social_club%membership(0)
46 end subroutine test2
47 ! CHECK-LABEL: func.func @_QMpPtest2(
48 ! CHECK: %{{.*}} = fir.call @_FortranAioInputDerivedType(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>, !fir.ref<none>) -> i1
50 subroutine test3(dtv)
51 interface write(formatted)
52 module procedure pwf
53 end interface write(formatted)
54 class(person), intent(inout) :: dtv
55 write(7, fmt='(DT)') dtv%next
56 end subroutine test3
57 ! CHECK-LABEL: func.func @_QMpPtest3(
58 ! CHECK: %{{.*}} = fir.call @_FortranAioOutputDerivedType(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>, !fir.ref<none>) -> i1
60 subroutine test4(social_club)
61 interface write(formatted)
62 module procedure pwf
63 end interface write(formatted)
64 class(club) :: social_club
65 write(7, fmt='(DT)') social_club%membership(0)
66 end subroutine test4
67 ! CHECK-LABEL: func.func @_QMpPtest4(
68 ! CHECK: %{{.*}} = fir.call @_FortranAioOutputDerivedType(%{{.*}}, %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<i8>, !fir.box<none>, !fir.ref<none>) -> i1
69 end module p