1 ! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
3 ! Test passing allocatables on caller side
5 ! CHECK-LABEL: func @_QPtest_scalar_call(
6 subroutine test_scalar_call()
8 subroutine test_scalar(x
)
12 real, allocatable
:: x
13 ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<f32>> {{{.*}}uniq_name = "_QFtest_scalar_callEx"}
15 ! CHECK: fir.call @_QPtest_scalar(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<f32>>>) -> ()
18 ! CHECK-LABEL: func @_QPtest_array_call(
19 subroutine test_array_call()
21 subroutine test_array(x
)
22 integer, allocatable
:: x(:)
25 integer, allocatable
:: x(:)
26 ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {{{.*}}uniq_name = "_QFtest_array_callEx"}
28 ! CHECK: fir.call @_QPtest_array(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> ()
31 ! CHECK-LABEL: func @_QPtest_char_scalar_deferred_call(
32 subroutine test_char_scalar_deferred_call()
34 subroutine test_char_scalar_deferred(x
)
35 character(:), allocatable
:: x
38 character(:), allocatable
:: x
39 ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {{{.*}}uniq_name = "_QFtest_char_scalar_deferred_callEx"}
40 call test_char_scalar_deferred(x
)
41 ! CHECK: fir.call @_QPtest_char_scalar_deferred(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> ()
44 ! CHECK-LABEL: func @_QPtest_char_scalar_explicit_call(
45 subroutine test_char_scalar_explicit_call(n
)
48 subroutine test_char_scalar_explicit(x
)
49 character(10), allocatable
:: x
52 character(10), allocatable
:: x
53 character(n
), allocatable
:: x2
54 ! CHECK-DAG: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,10>>> {{{.*}}uniq_name = "_QFtest_char_scalar_explicit_callEx"}
55 ! CHECK-DAG: %[[box2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {{{.*}}uniq_name = "_QFtest_char_scalar_explicit_callEx2"}
56 call test_char_scalar_explicit(x
)
57 ! CHECK: fir.call @_QPtest_char_scalar_explicit(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>) -> ()
58 call test_char_scalar_explicit(x2
)
59 ! CHECK: %[[box2cast:.*]] = fir.convert %[[box2]] : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>
60 ! CHECK: fir.call @_QPtest_char_scalar_explicit(%[[box2cast]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>) -> ()
63 ! CHECK-LABEL: func @_QPtest_char_array_deferred_call(
64 subroutine test_char_array_deferred_call()
66 subroutine test_char_array_deferred(x
)
67 character(:), allocatable
:: x(:)
70 character(:), allocatable
:: x(:)
71 ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>> {{{.*}}uniq_name = "_QFtest_char_array_deferred_callEx"}
72 call test_char_array_deferred(x
)
73 ! CHECK: fir.call @_QPtest_char_array_deferred(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>) -> ()
76 ! CHECK-LABEL: func @_QPtest_char_array_explicit_call(
77 subroutine test_char_array_explicit_call(n
)
80 subroutine test_char_array_explicit(x
)
81 character(10), allocatable
:: x(:)
84 character(10), allocatable
:: x(:)
85 character(n
), allocatable
:: x2(:)
86 ! CHECK-DAG: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>> {{{.*}}uniq_name = "_QFtest_char_array_explicit_callEx"}
87 ! CHECK-DAG: %[[box2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>> {{{.*}}uniq_name = "_QFtest_char_array_explicit_callEx2"}
88 call test_char_array_explicit(x
)
89 ! CHECK: fir.call @_QPtest_char_array_explicit(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>) -> ()
90 call test_char_array_explicit(x2
)
91 ! CHECK: %[[box2cast:.*]] = fir.convert %[[box2]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
92 ! CHECK: fir.call @_QPtest_char_array_explicit(%[[box2cast]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>) -> ()