| 1 |
! Test automatic deallocation of allocatable components |
| 2 |
! of local variables as described in Fortran 2018 standard |
| 3 |
! 9.7.3.2 point 2. and 3. |
| 4 |
! The allocatable components of local variables are local variables |
| 5 |
! themselves due to 5.4.3.2.2 p. 2, note 1. |
| 6 |
! RUN: bbc -emit-hlfir -o - -I nowhere %s | FileCheck %s |
| 7 |
|
| 8 |
module types |
| 9 |
type t1 |
| 10 |
real, allocatable :: x |
| 11 |
end type t1 |
| 12 |
type t2 |
| 13 |
type(t1) :: x |
| 14 |
end type t2 |
| 15 |
type, extends(t1) :: t3 |
| 16 |
end type t3 |
| 17 |
type, extends(t3) :: t4 |
| 18 |
end type t4 |
| 19 |
type, extends(t2) :: t5 |
| 20 |
end type t5 |
| 21 |
end module types |
| 22 |
|
| 23 |
subroutine test1() |
| 24 |
use types |
| 25 |
type(t1) :: x1 |
| 26 |
end subroutine test1 |
| 27 |
! CHECK-LABEL: func.func @_QPtest1() { |
| 28 |
! CHECK-DAG: %[[VAL_10:.*]] = fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> none |
| 29 |
! CHECK-DAG: %[[VAL_9]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>>) -> !fir.box<none> |
| 30 |
|
| 31 |
subroutine test1b() |
| 32 |
use types |
| 33 |
block |
| 34 |
type(t1) :: x1 |
| 35 |
end block |
| 36 |
end subroutine test1b |
| 37 |
! CHECK-LABEL: func.func @_QPtest1b() { |
| 38 |
! CHECK-DAG: %[[VAL_11:.*]] = fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> none |
| 39 |
! CHECK-DAG: %[[VAL_10]] = fir.convert %{{.*}} : (!fir.box<!fir.type<_QMtypesTt1{x:!fir.box<!fir.heap<f32>>}>>) -> !fir.box<none> |
| 40 |
|
| 41 |
subroutine test2() |
| 42 |
use types |
| 43 |
type(t2) :: x2 |
| 44 |
end subroutine test2 |
| 45 |
! CHECK-LABEL: func.func @_QPtest2() { |
| 46 |
! CHECK-DAG: %[[VAL_10:.*]] = fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> 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 |
|
| 49 |
subroutine test2b() |
| 50 |
use types |
| 51 |
block |
| 52 |
type(t2) :: x2 |
| 53 |
end block |
| 54 |
end subroutine test2b |
| 55 |
! CHECK-LABEL: func.func @_QPtest2b() { |
| 56 |
! CHECK-DAG: %[[VAL_11:.*]] = fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> 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 |
|
| 59 |
subroutine test3() |
| 60 |
use types |
| 61 |
type(t3) :: x3 |
| 62 |
end subroutine test3 |
| 63 |
! CHECK-LABEL: func.func @_QPtest3() { |
| 64 |
! CHECK-DAG: %[[VAL_10:.*]] = fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> 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 |
|
| 67 |
subroutine test3b() |
| 68 |
use types |
| 69 |
block |
| 70 |
type(t3) :: x3 |
| 71 |
end block |
| 72 |
end subroutine test3b |
| 73 |
! CHECK-LABEL: func.func @_QPtest3b() { |
| 74 |
! CHECK-DAG: %[[VAL_11:.*]] = fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> 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 |
|
| 77 |
subroutine test4() |
| 78 |
use types |
| 79 |
type(t4) :: x4 |
| 80 |
end subroutine test4 |
| 81 |
! CHECK-LABEL: func.func @_QPtest4() { |
| 82 |
! CHECK-DAG: %[[VAL_10:.*]] = fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> 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 |
|
| 85 |
subroutine test4b() |
| 86 |
use types |
| 87 |
block |
| 88 |
type(t4) :: x4 |
| 89 |
end block |
| 90 |
end subroutine test4b |
| 91 |
! CHECK-LABEL: func.func @_QPtest4b() { |
| 92 |
! CHECK-DAG: %[[VAL_11:.*]] = fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> 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 |
|
| 95 |
subroutine test5() |
| 96 |
use types |
| 97 |
type(t5) :: x5 |
| 98 |
end subroutine test5 |
| 99 |
! CHECK-LABEL: func.func @_QPtest5() { |
| 100 |
! CHECK-DAG: %[[VAL_10:.*]] = fir.call @_FortranADestroy(%[[VAL_9:.*]]) fastmath<contract> : (!fir.box<none>) -> 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 |
|
| 103 |
subroutine test5b() |
| 104 |
use types |
| 105 |
block |
| 106 |
type(t5) :: x5 |
| 107 |
end block |
| 108 |
end subroutine test5b |
| 109 |
! CHECK-LABEL: func.func @_QPtest5b() { |
| 110 |
! CHECK-DAG: %[[VAL_11:.*]] = fir.call @_FortranADestroy(%[[VAL_10:.*]]) fastmath<contract> : (!fir.box<none>) -> 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> |