Debian Codegraph @

gcc/testsuite/gfortran.dg/coarray/alloc_comp_7.f90

raw
1 ! { dg-do run }
2
3 module alloc_comp_module_7
4
5 public :: check
6
7 type :: foo
8 real :: x
9 integer, allocatable :: y(:)
10 contains
11 final :: foo_final
12 end type
13
14 contains
15
16 subroutine foo_final(f)
17 type(foo), intent(inout) :: f
18
19 if (allocated(f%y)) then
20 f%y = -1
21 end if
22 end subroutine foo_final
23
24 subroutine check()
25 block
26 type(foo), allocatable :: example[:] ! needs to be a coarray
27
28 allocate(example[*])
29 allocate(example%y(10))
30 example%x = 3.4
31 example%y = 4
32
33 deallocate(example%y)
34 deallocate(example)
35 end block ! example%y shall not be accessed here by the finalizer,
36 ! because example is already deallocated
37 end subroutine check
38 end module alloc_comp_module_7
39
40 program alloc_comp_7
41
42 use alloc_comp_module_7, only: check
43
44 implicit none
45
46 call check()
47
48 end program alloc_comp_7
49