94 lines · plain
1! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s2 3! Test passing allocatables on caller side4 5! CHECK-LABEL: func @_QPtest_scalar_call(6subroutine test_scalar_call()7 interface8 subroutine test_scalar(x)9 real, allocatable :: x10 end subroutine11 end interface12 real, allocatable :: x13 ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<f32>> {{{.*}}uniq_name = "_QFtest_scalar_callEx"}14 call test_scalar(x)15 ! CHECK: fir.call @_QPtest_scalar(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<f32>>>) -> ()16end subroutine17 18! CHECK-LABEL: func @_QPtest_array_call(19subroutine test_array_call()20 interface21 subroutine test_array(x)22 integer, allocatable :: x(:)23 end subroutine24 end interface25 integer, allocatable :: x(:)26 ! CHECK: %[[box:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {{{.*}}uniq_name = "_QFtest_array_callEx"}27 call test_array(x)28 ! CHECK: fir.call @_QPtest_array(%[[box]]) {{.*}}: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> ()29end subroutine30 31! CHECK-LABEL: func @_QPtest_char_scalar_deferred_call(32subroutine test_char_scalar_deferred_call()33 interface34 subroutine test_char_scalar_deferred(x)35 character(:), allocatable :: x36 end subroutine37 end interface38 character(:), allocatable :: x39 ! 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,?>>>>) -> ()42end subroutine43 44! CHECK-LABEL: func @_QPtest_char_scalar_explicit_call(45subroutine test_char_scalar_explicit_call(n)46 integer :: n47 interface48 subroutine test_char_scalar_explicit(x)49 character(10), allocatable :: x50 end subroutine51 end interface52 character(10), allocatable :: x53 character(n), allocatable :: x254 ! 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>>>>) -> ()61end subroutine62 63! CHECK-LABEL: func @_QPtest_char_array_deferred_call(64subroutine test_char_array_deferred_call()65 interface66 subroutine test_char_array_deferred(x)67 character(:), allocatable :: x(:)68 end subroutine69 end interface70 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,?>>>>>) -> ()74end subroutine75 76! CHECK-LABEL: func @_QPtest_char_array_explicit_call(77subroutine test_char_array_explicit_call(n)78 integer :: n79 interface80 subroutine test_char_array_explicit(x)81 character(10), allocatable :: x(:)82 end subroutine83 end interface84 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>>>>>) -> ()93end subroutine94