| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-w -fdump-tree-original" } |
| 3 |
! |
| 4 |
! Contributed by Sebastian Bardeau <[email protected]> |
| 5 |
! |
| 6 |
module mymod |
| 7 |
type mysubtype |
| 8 |
integer(kind=4), allocatable :: a(:) |
| 9 |
end type mysubtype |
| 10 |
type :: mytype |
| 11 |
integer :: i |
| 12 |
type(mysubtype) :: sub |
| 13 |
contains |
| 14 |
final :: mytype_final |
| 15 |
end type mytype |
| 16 |
contains |
| 17 |
subroutine mysubtype_final(sub) |
| 18 |
type(mysubtype), intent(inout) :: sub |
| 19 |
print *,'MYSUBTYPE>FINAL' |
| 20 |
if (allocated(sub%a)) deallocate(sub%a) |
| 21 |
end subroutine mysubtype_final |
| 22 |
subroutine mytype_final(typ) |
| 23 |
type(mytype), intent(inout) :: typ |
| 24 |
print *,"MYTYPE>FINAL" |
| 25 |
call mysubtype_final(typ%sub) |
| 26 |
end subroutine mytype_final |
| 27 |
end module mymod |
| 28 |
! |
| 29 |
program myprog |
| 30 |
use mymod |
| 31 |
type(mytype), pointer :: c |
| 32 |
print *,"Before allocation" |
| 33 |
allocate(c) |
| 34 |
print *,"After allocation" |
| 35 |
end program myprog |
| 36 |
! Final subroutines were called with std=gnu and -w = > 14 "_final"s. |
| 37 |
! { dg-final { scan-tree-dump-times "_final" 12 "original" } } |