1 ! Test that any temps generated for IO options are deallocated at the right
2 ! time (after they are used, but before exiting the block where they were
4 ! RUN: bbc -emit-fir -o - %s | FileCheck %s
6 ! CHECK-LABEL: func @_QPtest_temp_io_options(
7 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>{{.*}}) {
8 subroutine test_temp_io_options(status
)
10 function gen_temp_character()
11 character(:), allocatable
:: gen_temp_character
15 open (10, encoding
=gen_temp_character(), file
=gen_temp_character(), pad
=gen_temp_character(), iostat
=status
)
16 ! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>>
17 ! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>>
18 ! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>>
19 ! CHECK: fir.call @_FortranAioBeginOpenUnit
20 ! CHECK: %[[VAL_15:.*]] = fir.call @_QPgen_temp_character() {{.*}}: () -> !fir.box<!fir.heap<!fir.char<1,?>>>
21 ! CHECK: fir.save_result %[[VAL_15]] to %[[VAL_3]] : !fir.box<!fir.heap<!fir.char<1,?>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
22 ! CHECK: %[[VAL_21:.*]] = fir.call @_FortranAioSetEncoding
23 ! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
24 ! CHECK: %[[VAL_23:.*]] = fir.box_addr %[[VAL_22]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
25 ! CHECK: fir.freemem %[[VAL_23]] : !fir.heap<!fir.char<1,?>>
26 ! CHECK: fir.if %[[VAL_21]] {
27 ! CHECK: %[[VAL_27:.*]] = fir.call @_QPgen_temp_character() {{.*}}: () -> !fir.box<!fir.heap<!fir.char<1,?>>>
28 ! CHECK: fir.save_result %[[VAL_27]] to %[[VAL_2]] : !fir.box<!fir.heap<!fir.char<1,?>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
29 ! CHECK: %[[VAL_33:.*]] = fir.call @_FortranAioSetFile
30 ! CHECK: %[[VAL_34:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
31 ! CHECK: %[[VAL_35:.*]] = fir.box_addr %[[VAL_34]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
32 ! CHECK: fir.freemem %[[VAL_35]] : !fir.heap<!fir.char<1,?>>
33 ! CHECK: fir.if %[[VAL_33]] {
34 ! CHECK: %[[VAL_39:.*]] = fir.call @_QPgen_temp_character() {{.*}}: () -> !fir.box<!fir.heap<!fir.char<1,?>>>
35 ! CHECK: fir.save_result %[[VAL_39]] to %[[VAL_1]] : !fir.box<!fir.heap<!fir.char<1,?>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
36 ! CHECK: fir.call @_FortranAioSetPad
37 ! CHECK: %[[VAL_46:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
38 ! CHECK: %[[VAL_47:.*]] = fir.box_addr %[[VAL_46]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
39 ! CHECK: fir.freemem %[[VAL_47]] : !fir.heap<!fir.char<1,?>>
42 ! CHECK: fir.call @_FortranAioEndIoStatement