! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s ! CHECK-LABEL: func @_QPto_from_only subroutine to_from_only integer, allocatable :: from(:), to(:) ! CHECK: %[[a1:.*]] = fir.alloca !fir.box>> ! CHECK: %[[from:.*]]:2 = hlfir.declare %[[a1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFto_from_onlyEfrom"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) ! CHECK: %[[b1:.*]] = fir.alloca !fir.box>> ! CHECK: %[[to:.*]]:2 = hlfir.declare %[[b1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFto_from_onlyEto"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) allocate(from(20)) ! CHECK: %[[errMsg:.*]] = fir.absent !fir.box ! CHECK: %[[false:.*]] = arith.constant false ! CHECK: %[[to_conv:.*]] = fir.convert %[[to]]#0 : (!fir.ref>>>) -> !fir.ref> ! CHECK: %[[from_conv:.*]] = fir.convert %[[from]]#0 : (!fir.ref>>>) -> !fir.ref> call move_alloc(from, to) ! CHECK: fir.call @_FortranAMoveAlloc(%[[to_conv]], %[[from_conv]], %{{.*}}, %[[false]], %[[errMsg]], %{{.*}}, %{{.*}}) fastmath : (!fir.ref>, !fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 end subroutine to_from_only ! CHECK-LABEL: func @_QPto_from_stat subroutine to_from_stat integer, allocatable :: from(:), to(:) integer :: stat ! CHECK-DAG: %[[a1:.*]] = fir.alloca !fir.box>> ! CHECK-DAG: %[[from:.*]]:2 = hlfir.declare %[[a1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFto_from_statEfrom"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) ! CHECK-DAG: %[[b1:.*]] = fir.alloca !fir.box>> ! CHECK-DAG: %[[to:.*]]:2 = hlfir.declare %[[b1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFto_from_statEto"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) allocate(from(20)) ! CHECK: %[[errMsg:.*]] = fir.absent !fir.box ! CHECK: %[[true:.*]] = arith.constant true ! CHECK: %[[to_conv:.*]] = fir.convert %[[to]]#0 : (!fir.ref>>>) -> !fir.ref> ! CHECK: %[[from_conv:.*]] = fir.convert %[[from]]#0 : (!fir.ref>>>) -> !fir.ref> call move_alloc(from, to, stat) ! CHECK: %[[stat:.*]] = fir.call @_FortranAMoveAlloc(%[[to_conv]], %[[from_conv]], %{{.*}}, %[[true]], %[[errMsg]], %{{.*}}, %{{.*}}) fastmath : (!fir.ref>, !fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 end subroutine to_from_stat ! CHECK-LABEL: func @_QPto_from_stat_errmsg subroutine to_from_stat_errmsg integer, allocatable :: from(:), to(:) integer :: stat character :: errMsg*64 ! CHECK-DAG: %[[errMsg1:.*]] = fir.alloca !fir.char<1,64> ! CHECK-DAG: %[[errMsg_decl:.*]]:2 = hlfir.declare %[[errMsg1]] typeparams {{.*}} {uniq_name = "_QFto_from_stat_errmsgEerrmsg"} : (!fir.ref>, index) -> (!fir.ref>, !fir.ref>) ! CHECK-DAG: %[[a1:.*]] = fir.alloca !fir.box>> ! CHECK-DAG: %[[from:.*]]:2 = hlfir.declare %[[a1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFto_from_stat_errmsgEfrom"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) ! CHECK-DAG: %[[b1:.*]] = fir.alloca !fir.box>> ! CHECK-DAG: %[[to:.*]]:2 = hlfir.declare %[[b1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFto_from_stat_errmsgEto"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) allocate(from(20)) ! CHECK: %[[errMsg2:.*]] = fir.embox %[[errMsg_decl]]#0 : (!fir.ref>) -> !fir.box> ! CHECK: %[[true:.*]] = arith.constant true ! CHECK: %[[to_conv:.*]] = fir.convert %[[to]]#0 : (!fir.ref>>>) -> !fir.ref> ! CHECK: %[[from_conv:.*]] = fir.convert %[[from]]#0 : (!fir.ref>>>) -> !fir.ref> ! CHECK: %[[errMsg3:.*]] = fir.convert %[[errMsg2]] : (!fir.box>) -> !fir.box call move_alloc(from, to, stat, errMsg) ! CHECK: %[[stat:.*]] = fir.call @_FortranAMoveAlloc(%[[to_conv]], %[[from_conv]], %{{.*}}, %[[true]], %[[errMsg3]], %{{.*}}, %{{.*}}) fastmath : (!fir.ref>, !fir.ref>, !fir.ref, i1, !fir.box, !fir.ref, i32) -> i32 end subroutine to_from_stat_errmsg