! Test lowering of calls to interface with pointer or allocatable ! assumed rank dummy arguments. ! RUN: bbc -emit-hlfir -o - %s | FileCheck %s module ifaces_ptr_alloc interface subroutine alloc_assumed_rank(y) real, allocatable :: y(..) end subroutine subroutine pointer_assumed_rank(y) real, optional, pointer :: y(..) end subroutine subroutine pointer_assumed_rank2(y) real, intent(in), pointer :: y(..) end subroutine end interface end module subroutine scalar_alloc_to_assumed_rank(x) use ifaces_ptr_alloc, only : alloc_assumed_rank real, allocatable :: x call alloc_assumed_rank(x) end subroutine ! CHECK-LABEL: func.func @_QPscalar_alloc_to_assumed_rank( ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>> {fir.bindc_name = "x"}) { ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFscalar_alloc_to_assumed_rankEx"} : (!fir.ref>>, !fir.dscope) -> (!fir.ref>>, !fir.ref>>) ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref>>) -> !fir.ref>>> ! CHECK: fir.call @_QPalloc_assumed_rank(%[[VAL_2]]) fastmath : (!fir.ref>>>) -> () subroutine r2_alloc_to_assumed_rank(x) use ifaces_ptr_alloc, only : alloc_assumed_rank real, allocatable :: x(:, :) call alloc_assumed_rank(x) end subroutine ! CHECK-LABEL: func.func @_QPr2_alloc_to_assumed_rank( ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>>> {fir.bindc_name = "x"}) { ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFr2_alloc_to_assumed_rankEx"} : (!fir.ref>>>, !fir.dscope) -> (!fir.ref>>>, !fir.ref>>>) ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref>>>) -> !fir.ref>>> ! CHECK: fir.call @_QPalloc_assumed_rank(%[[VAL_2]]) fastmath : (!fir.ref>>>) -> () subroutine scalar_pointer_to_assumed_rank(x) use ifaces_ptr_alloc, only : pointer_assumed_rank real, pointer :: x call pointer_assumed_rank(x) end subroutine ! CHECK-LABEL: func.func @_QPscalar_pointer_to_assumed_rank( ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>> {fir.bindc_name = "x"}) { ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFscalar_pointer_to_assumed_rankEx"} : (!fir.ref>>, !fir.dscope) -> (!fir.ref>>, !fir.ref>>) ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref>>) -> !fir.ref>>> ! CHECK: fir.call @_QPpointer_assumed_rank(%[[VAL_2]]) fastmath : (!fir.ref>>>) -> () subroutine r2_pointer_to_assumed_rank(x) use ifaces_ptr_alloc, only : pointer_assumed_rank real, pointer :: x(:, :) call pointer_assumed_rank(x) end subroutine ! CHECK-LABEL: func.func @_QPr2_pointer_to_assumed_rank( ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>>> {fir.bindc_name = "x"}) { ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFr2_pointer_to_assumed_rankEx"} : (!fir.ref>>>, !fir.dscope) -> (!fir.ref>>>, !fir.ref>>>) ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref>>>) -> !fir.ref>>> ! CHECK: fir.call @_QPpointer_assumed_rank(%[[VAL_2]]) fastmath : (!fir.ref>>>) -> () subroutine r2_target_to_pointer_assumed_rank(x) use ifaces_ptr_alloc, only : pointer_assumed_rank2 real, target :: x(:, :) call pointer_assumed_rank2(x) end subroutine ! CHECK-LABEL: func.func @_QPr2_target_to_pointer_assumed_rank( ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box> {fir.bindc_name = "x", fir.target}) { ! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box>> ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFr2_target_to_pointer_assumed_rankEx"} : (!fir.box>, !fir.dscope) -> (!fir.box>, !fir.box>) ! CHECK: %[[VAL_3:.*]] = fir.rebox %[[VAL_2]]#1 : (!fir.box>) -> !fir.box>> ! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref>>> ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_1]] : (!fir.ref>>>) -> !fir.ref>>> ! CHECK: fir.call @_QPpointer_assumed_rank2(%[[VAL_4]]) fastmath : (!fir.ref>>>) -> ()