32 lines · plain
1! RUN: bbc -emit-hlfir -frepack-arrays %s -o - -I nowhere | FileCheck --check-prefixes=CHECK %s2 3! Check that the original array is copied on entry to the subroutine4! before it is being finalized, otherwise the finalization routine5! may read the uninitialized temporary.6! Verify that fir.pack_array does not have no_copy attribute.7 8module m9 type t10 contains11 final :: my_final12 end type t13 interface14 subroutine my_final(x)15 type(t) :: x(:)16 end subroutine my_final17 end interface18contains19! CHECK-LABEL: func.func @_QMmPtest(20! CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.class<!fir.array<?x!fir.type<_QMmTt>>> {fir.bindc_name = "x"}) {21 subroutine test(x)22 class(t), intent(out) :: x(:)23! CHECK: %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]] heap whole : (!fir.class<!fir.array<?x!fir.type<_QMmTt>>>) -> !fir.class<!fir.array<?x!fir.type<_QMmTt>>>24! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]]25! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#126! CHECK: fir.call @_FortranADestroy(%[[VAL_4]]) fastmath<contract> : (!fir.box<none>) -> ()27! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_3]]#128! CHECK: fir.call @_FortranAInitialize(%[[VAL_7]]29! CHECK: fir.unpack_array %[[VAL_2]] to %[[VAL_0]] heap : !fir.class<!fir.array<?x!fir.type<_QMmTt>>>30 end subroutine test31end module m32