112 lines · plain
1! Test automatic deallocation of allocatable components2! of local variables as described in Fortran 2018 standard3! 9.7.3.2 point 2. and 3.4! The allocatable components of local variables are local variables5! themselves due to 5.4.3.2.2 p. 2, note 1.6! RUN: bbc -emit-hlfir -o - -I nowhere %s | FileCheck %s7 8module types9 type t110 real, allocatable :: x11 end type t112 type t213 type(t1) :: x14 end type t215 type, extends(t1) :: t316 end type t317 type, extends(t3) :: t418 end type t419 type, extends(t2) :: t520 end type t521end module types22 23subroutine test1()24 use types25 type(t1) :: x126end subroutine test127! CHECK-LABEL: func.func @_QPtest1() {28! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> ()29! CHECK-DAG: %[[VAL_9]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>>) -> !fir.box<none>30 31subroutine test1b()32 use types33 block34 type(t1) :: x135 end block36end subroutine test1b37! CHECK-LABEL: func.func @_QPtest1b() {38! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> ()39! CHECK-DAG: %[[VAL_10]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>>) -> !fir.box<none>40 41subroutine test2()42 use types43 type(t2) :: x244end subroutine test245! CHECK-LABEL: func.func @_QPtest2() {46! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> ()47! CHECK-DAG: %[[VAL_9]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt2{x:!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>}>>) -> !fir.box<none>48 49subroutine test2b()50 use types51 block52 type(t2) :: x253 end block54end subroutine test2b55! CHECK-LABEL: func.func @_QPtest2b() {56! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> ()57! CHECK-DAG: %[[VAL_10]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt2{x:!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>}>>) -> !fir.box<none>58 59subroutine test3()60 use types61 type(t3) :: x362end subroutine test363! CHECK-LABEL: func.func @_QPtest3() {64! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> ()65! CHECK-DAG: %[[VAL_9]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt3{t1:!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>}>>) -> !fir.box<none>66 67subroutine test3b()68 use types69 block70 type(t3) :: x371 end block72end subroutine test3b73! CHECK-LABEL: func.func @_QPtest3b() {74! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> ()75! CHECK-DAG: %[[VAL_10]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt3{t1:!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>}>>) -> !fir.box<none>76 77subroutine test4()78 use types79 type(t4) :: x480end subroutine test481! CHECK-LABEL: func.func @_QPtest4() {82! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> ()83! CHECK-DAG: %[[VAL_9]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt4{t3:!fir.type<_QMtypesTt3{t1:!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>}>}>>) -> !fir.box<none>84 85subroutine test4b()86 use types87 block88 type(t4) :: x489 end block90end subroutine test4b91! CHECK-LABEL: func.func @_QPtest4b() {92! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> ()93! CHECK-DAG: %[[VAL_10]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt4{t3:!fir.type<_QMtypesTt3{t1:!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>}>}>>) -> !fir.box<none>94 95subroutine test5()96 use types97 type(t5) :: x598end subroutine test599! CHECK-LABEL: func.func @_QPtest5() {100! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> ()101! CHECK-DAG: %[[VAL_9]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt5{t2:!fir.type<_QMtypesTt2{x:!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>}>}>>) -> !fir.box<none>102 103subroutine test5b()104 use types105 block106 type(t5) :: x5107 end block108end subroutine test5b109! CHECK-LABEL: func.func @_QPtest5b() {110! CHECK-DAG: fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> ()111! CHECK-DAG: %[[VAL_10]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt5{t2:!fir.type<_QMtypesTt2{x:!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>}>}>>) -> !fir.box<none>112