1 ! RUN: bbc %s -emit-fir -o - | FileCheck %s
2 ! UNSUPPORTED: system-windows
9 ! CHECK: call {{.*}}BeginOpenUnit
10 ! CHECK-DAG: call {{.*}}SetFile
11 ! CHECK-DAG: call {{.*}}SetAccess
12 ! CHECK: call {{.*}}EndIoStatement
13 open(8, file
="foo", access
="sequential")
15 ! CHECK: call {{.*}}BeginBackspace
16 ! CHECK: call {{.*}}EndIoStatement
19 ! CHECK: call {{.*}}BeginFlush
20 ! CHECK: call {{.*}}EndIoStatement
23 ! CHECK: call {{.*}}BeginRewind
24 ! CHECK: call {{.*}}EndIoStatement
27 ! CHECK: call {{.*}}BeginEndfile
28 ! CHECK: call {{.*}}EndIoStatement
31 ! CHECK: call {{.*}}BeginWaitAll(%{{.*}}, %{{.*}}, %{{.*}})
32 ! CHECK: call {{.*}}EndIoStatement
35 ! CHECK: call {{.*}}BeginExternalListInput
36 ! CHECK: call {{.*}}InputInteger
37 ! CHECK: call {{.*}}InputReal32
38 ! CHECK: call {{.*}}EndIoStatement
41 ! CHECK: call {{.*}}BeginExternalListOutput
42 ! CHECK: call {{.*}}OutputInteger32
43 ! CHECK: call {{.*}}OutputReal32
44 ! CHECK: call {{.*}}EndIoStatement
47 ! CHECK: call {{.*}}BeginClose
48 ! CHECK: call {{.*}}EndIoStatement
51 ! CHECK: call {{.*}}BeginExternalListOutput
52 ! CHECK: call {{.*}}OutputAscii
53 ! CHECK: call {{.*}}EndIoStatement
54 print *, "A literal string"
56 ! CHECK: call {{.*}}BeginInquireUnit
57 ! CHECK: call {{.*}}EndIoStatement
58 inquire(4, EXIST
=existsvar
)
60 ! CHECK: call {{.*}}BeginInquireFile
61 ! CHECK: call {{.*}}EndIoStatement
62 inquire(FILE
="fail.f90", EXIST
=existsvar
)
64 ! CHECK: call {{.*}}BeginInquireIoLength
65 ! CHECK-COUNT-3: call {{.*}}OutputDescriptor
66 ! CHECK: call {{.*}}EndIoStatement
67 inquire (iolength
=length
) existsvar
, length
, a
70 ! CHECK-LABEL: internalnamelistio
71 subroutine internalNamelistIO()
72 ! CHECK: %[[internal:[0-9]+]] = fir.alloca !fir.char<1,12> {bindc_name = "internal"
73 character(12) :: internal
76 ! CHECK: %[[internal_:[0-9]+]] = fir.convert %[[internal]] : (!fir.ref<!fir.char<1,12>>) -> !fir.ref<i8>
77 ! CHECK: %[[cookie:[0-9]+]] = fir.call @_FortranAioBeginInternalListOutput(%[[internal_]]
78 ! CHECK: fir.call @_FortranAioOutputNamelist(%[[cookie]]
79 ! CHECK: fir.call @_FortranAioEndIoStatement(%[[cookie]]
80 write(internal
,nml
=nml
)
83 ! Tests the 4 basic inquire formats
84 ! CHECK-LABEL: func @_QPinquire_test
85 subroutine inquire_test(ch
, i
, b
)
92 ! CHECK: %[[sugar:.*]] = fir.call {{.*}}BeginInquireUnit
93 ! CHECK: call {{.*}}InquireCharacter(%[[sugar]], %c{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64, !fir.ref<i8>, i64) -> i1
94 ! CHECK: call {{.*}}EndIoStatement
98 ! CHECK: %[[oatmeal:.*]] = fir.call {{.*}}BeginInquireUnit
99 ! CHECK: call @_FortranAioInquireInteger64(%[[oatmeal]], %c{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64, !fir.ref<i64>, i32) -> i1
100 ! CHECK: call {{.*}}EndIoStatement
104 ! CHECK: %[[snicker:.*]] = fir.call {{.*}}BeginInquireUnit
105 ! CHECK: call @_FortranAioInquireLogical(%[[snicker]], %c{{.*}}, %[[b:.*]]) {{.*}}: (!fir.ref<i8>, i64, !fir.ref<i1>) -> i1
106 ! CHECK: call {{.*}}EndIoStatement
107 inquire(90, opened
=b
)
110 ! CHECK-DAG: %[[chip:.*]] = fir.call {{.*}}BeginInquireUnit
111 ! CHECK-DAG: fir.call @_QPid_func
112 ! CHECK: call @_FortranAioInquirePendingId(%[[chip]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64, !fir.ref<i1>) -> i1
113 ! CHECK: call {{.*}}EndIoStatement
114 inquire(91, id
=id_func(), pending
=b
)
115 end subroutine inquire_test
117 ! CHECK-LABEL: @_QPboz
119 ! CHECK: fir.call @_FortranAioOutputInteger8(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i8) -> i1
120 ! CHECK: fir.call @_FortranAioOutputInteger16(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i16) -> i1
121 ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i32) -> i1
122 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
123 ! CHECK: fir.call @_FortranAioOutputInteger128(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i128) -> i1
124 print '(*(Z3))', 96_1, 96_2, 96_4, 96_8, 96_16
126 ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i32) -> i1
127 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
128 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
129 print '(I3,2Z44)', 40, 2**40_8, 2**40_8+1
131 ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i32) -> i1
132 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
133 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
134 print '(I3,2I44)', 40, 1099511627776, 1099511627777
136 ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i32) -> i1
137 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
138 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
139 print '(I3,2O44)', 40, 2**40_8, 2**40_8+1
141 ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i32) -> i1
142 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
143 ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, i64) -> i1
144 print '(I3,2B44)', 40, 2**40_8, 2**40_8+1