1 ! Test HLFIR lowering of user defined elemental procedure references
2 ! with finalizable results. Verify that the elemental results
3 ! are not destroyed inside hlfir.elemental.
4 ! RUN: bbc -emit-hlfir -o - -I nowhere %s 2>&1 | FileCheck %s
12 pure
subroutine finalize(x
)
13 type(t
), intent(inout
) :: x
14 end subroutine finalize
20 elemental
function elem(x
)
22 type(t
), intent(in
) :: x
29 ! CHECK-LABEL: func.func @_QPtest1(
30 ! CHECK: %[[VAL_6:.*]] = hlfir.elemental %{{.*}} : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {
31 ! CHECK-NOT: fir.call @_FortranADestroy
32 ! CHECK: hlfir.destroy %[[VAL_6]] finalize : !hlfir.expr<?x!fir.type<_QMtypesTt>>
37 elemental
function elem(x
)
39 type(t
), intent(in
) :: x
42 elemental
function elem2(x
, y
)
44 type(t
), intent(in
) :: x
, y
49 x
= elem2(elem(x
), elem(x
))
51 ! CHECK-LABEL: func.func @_QPtest2(
52 ! CHECK: %[[VAL_8:.*]] = hlfir.elemental %{{.*}} : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {
53 ! CHECK-NOT: fir.call @_FortranADestroy
54 ! CHECK: %[[VAL_16:.*]] = hlfir.elemental %{{.*}} : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {
55 ! CHECK-NOT: fir.call @_FortranADestroy
56 ! CHECK: %[[VAL_23:.*]] = hlfir.elemental %{{.*}} : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {
57 ! CHECK-NOT: fir.call @_FortranADestroy
58 ! CHECK: hlfir.destroy %[[VAL_23]] finalize : !hlfir.expr<?x!fir.type<_QMtypesTt>>
59 ! CHECK: hlfir.destroy %[[VAL_16]] finalize : !hlfir.expr<?x!fir.type<_QMtypesTt>>
60 ! CHECK: hlfir.destroy %[[VAL_8]] finalize : !hlfir.expr<?x!fir.type<_QMtypesTt>>