1 ! RUN: bbc -emit-fir -o - %s | FileCheck %s
2 ! UNSUPPORTED: system-windows
10 ! CHECK: call {{.*}}BeginExternalFormattedInput
11 ! CHECK: call {{.*}}EnableHandlers
12 ! CHECK: call {{.*}}SetAdvance
13 ! CHECK: call {{.*}}InputReal
14 ! CHECK: call {{.*}}GetIoMsg
15 ! CHECK: call {{.*}}EndIoStatement
16 ! CHECK: fir.select %{{.*}} : index [-2, ^bb4, -1, ^bb3, 0, ^bb1, unit, ^bb2]
17 read(*, '(A)', ADVANCE
='NO', ERR
=10, END=20, EOR
=30, IOSTAT
=s
, IOMSG
=m
) f
20 10 exx
= 'Err'; goto 90
21 20 exx
= 'End'; goto 90
22 30 exx
= 'Eor'; goto 90
23 90 print*, exx
, c
, m
, s
26 ! CHECK-LABEL: func @_QPcontrol0
27 subroutine control0(n
) ! no I/O condition specifier control flow
28 dimension c(n
), d(n
,n
), e(n
,n
), f(n
)
30 ! CHECK: BeginExternalFormattedInput
52 ! CHECK: EndIoStatement
54 read(*,'(F7.2)', advance
='no') a
, b
, (c(j
), (d(k
,j
), e(k
,j
), k
=1,n
), f(j
), j
=1,n
), g
57 ! CHECK-LABEL: func @_QPcontrol1
58 subroutine control1(n
) ! I/O condition specifier control flow
59 ! CHECK: BeginExternalFormattedInput
60 ! CHECK: EnableHandlers
67 ! CHECK: fir.iterate_while
71 ! CHECK: fir.iterate_while
80 ! CHECK: EndIoStatement
81 dimension c(n
), d(n
,n
), e(n
,n
), f(n
)
82 read(*,'(F7.2)', iostat
=mm
, advance
='no') a
, b
, (c(j
), (d(k
,j
), e(k
,j
), k
=1,n
), f(j
), j
=1,n
), g
85 ! CHECK-LABEL: func @_QPcontrol2
86 subroutine control2() ! I/O condition specifier control flow (use index result)
88 ! CHECK: BeginExternalFormattedOutput
89 ! CHECK: EnableHandlers
90 ! CHECK: :2 = fir.iterate_while
97 ! CHECK: fir.result %false
100 ! CHECK: fir.result %false
101 ! CHECK: = arith.addi %arg0, %c1
102 ! CHECK: = arith.select
104 ! CHECK: fir.if %{{[0-9]*}}#1
105 ! CHECK: OutputInteger
106 ! CHECK: EndIoStatement
107 write(*,'(8F4.1,I5)',iostat
=m
) (c
,d
,j
=11,14), j
110 ! CHECK-LABEL: func @_QPcontrol3
111 subroutine control3
! I/O condition specifier control flow
112 character(10) :: internal(2) = ['aaa','bbb']
114 ! CHECK: BeginInternalArrayListInput
115 ! CHECK: EnableHandlers
116 ! CHECK: InputDescriptor
117 ! CHECK: %[[V_15:[0-9]+]] = fir.call @_FortranAioEndIoStatement
118 ! CHECK: %[[V_16:[0-9]+]] = fir.convert %[[V_15]] : (i32) -> index
119 ! CHECK: fir.select %[[V_16]] : index [-2, ^bb1, -1, ^bb1, 0, ^bb1, unit, ^bb2]
120 read(internal
,*,err
=666,iostat
=stat
) k
! set stat to IOSTAT_END (-1)
121 ! CHECK: ^bb1: // 3 preds: ^bb0, ^bb0, ^bb0
122 ! CHECK: StopStatementText
123 ! CHECK: fir.unreachable
124 stop 'fallthrough -> ok'
125 ! CHECK: ^bb2: // pred: ^bb0
126 ! CHECK: BeginExternalListOutput
128 ! CHECK: EndIoStatement
132 ! CHECK-LABEL: func @_QPloopnest
136 ! CHECK: BeginExternalListOutput
137 ! CHECK: EnableHandlers
138 ! CHECK: {{.*}}:2 = fir.iterate_while ({{.*}} = {{.*}} to {{.*}} step {{.*}}) and ({{.*}} = {{.*}}) -> (index, i1) {
139 ! CHECK: fir.if {{.*}} -> (i1) {
140 ! CHECK: {{.*}}:2 = fir.iterate_while ({{.*}} = {{.*}} to {{.*}} step {{.*}}) and ({{.*}} = {{.*}}) -> (index, i1) {
141 ! CHECK: fir.if {{.*}} -> (i1) {
142 ! CHECK: OutputInteger32
143 ! CHECK: fir.result {{.*}} : i1
145 ! CHECK: fir.result {{.*}} : i1
147 ! CHECK: fir.result {{.*}}, {{.*}} : index, i1
149 ! CHECK: fir.result {{.*}}#1 : i1
151 ! CHECK: fir.result {{.*}} : i1
153 ! CHECK: fir.result {{.*}}, {{.*}} : index, i1
155 ! CHECK: EndIoStatement
156 write(*,*,err
=66) ((aa(j
,k
)+j
+k
,j
=1,3),k
=1,3)
160 ! CHECK-LABEL: func @_QPimpliedformat
161 subroutine impliedformat
162 ! CHECK: BeginExternalListInput(%c-1
164 ! CHECK: EndIoStatement(%3) {{.*}}: (!fir.ref<i8>) -> i32
166 ! CHECK: BeginExternalListOutput(%c-1
167 ! CHECK: OutputReal32
168 ! CHECK: EndIoStatement