| 1 |
! { dg-do run } |
| 2 |
! { dg-additional-options "-fdump-tree-original" } |
| 3 |
! |
| 4 |
! PR fortran/92587 |
| 5 |
! |
| 6 |
|
| 7 |
module m |
| 8 |
implicit none (type, external) |
| 9 |
type t2 |
| 10 |
contains |
| 11 |
final :: fini |
| 12 |
end type |
| 13 |
type t3 |
| 14 |
type(t2) :: a |
| 15 |
end type |
| 16 |
type, extends(t3) :: t4 |
| 17 |
end type |
| 18 |
class(t4), allocatable :: y |
| 19 |
class(t4), allocatable :: z |
| 20 |
integer :: fini_cnt = 0 |
| 21 |
contains |
| 22 |
subroutine sub |
| 23 |
y = z |
| 24 |
end |
| 25 |
subroutine fini(x) |
| 26 |
type(t2) :: x |
| 27 |
fini_cnt = fini_cnt + 1 |
| 28 |
end |
| 29 |
end |
| 30 |
|
| 31 |
module m2 |
| 32 |
use m |
| 33 |
implicit none (type, external) |
| 34 |
type, extends(t3) :: t5 |
| 35 |
end type |
| 36 |
type, extends(t3) :: t6 |
| 37 |
contains |
| 38 |
final :: fin2 |
| 39 |
end type |
| 40 |
integer :: fin2_cnt = 0 |
| 41 |
contains |
| 42 |
subroutine bar(x, y, z) |
| 43 |
class(t4), allocatable, intent(out) :: x |
| 44 |
class(t5), allocatable, intent(out) :: y |
| 45 |
class(t6), allocatable, intent(out) :: z |
| 46 |
end |
| 47 |
subroutine fin2 (x) |
| 48 |
type(t6) :: x |
| 49 |
fin2_cnt = fin2_cnt + 1 |
| 50 |
end |
| 51 |
end |
| 52 |
|
| 53 |
use m |
| 54 |
use m2 |
| 55 |
implicit none (type, external) |
| 56 |
class(t4), allocatable :: x2 |
| 57 |
class(t5), allocatable :: y2 |
| 58 |
class(t6), allocatable :: z2 |
| 59 |
|
| 60 |
if (fini_cnt /= 0 .or. fin2_cnt /= 0) stop 1 |
| 61 |
call bar (x2, y2, z2) |
| 62 |
if (fini_cnt /= 0 .or. fin2_cnt /= 0) stop 2 |
| 63 |
if (allocated(x2) .or. allocated(y2) .or. allocated(z2)) stop 3 |
| 64 |
|
| 65 |
allocate(t4 :: x2) |
| 66 |
allocate(t5 :: y2) |
| 67 |
allocate(t6 :: z2) |
| 68 |
call bar (x2, y2, z2) |
| 69 |
if (fini_cnt /= 3 .or. fin2_cnt /= 1) stop 4 |
| 70 |
if (allocated(x2) .or. allocated(y2) .or. allocated(z2)) stop 5 |
| 71 |
|
| 72 |
allocate(t6 :: z2) |
| 73 |
call bar (x2, y2, z2) |
| 74 |
if (fini_cnt /= 4 .or. fin2_cnt /= 2) stop 6 |
| 75 |
if (allocated(x2) .or. allocated(y2) .or. allocated(z2)) stop 7 |
| 76 |
end |
| 77 |
|
| 78 |
! { dg-final { scan-tree-dump "__final_m_T2 \\\(struct" "original" } } |
| 79 |
! { dg-final { scan-tree-dump "__final_m_T3 \\\(struct" "original" } } |
| 80 |
! { dg-final { scan-tree-dump "__final_m2_T6 \\\(struct" "original" } } |