aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/auto_dealloc_1.f90
blob: 7e5fbd1486e6e27e5028f7dcea54e73cd5d1d2fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
! { dg-do compile }
! { dg-options "-fdump-tree-original" }
!
! PR 41586: Allocatable _scalars_ are never auto-deallocated
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>

module automatic_deallocation

  type t0
    integer :: i
  end type

  type t1
    real :: pi = 3.14
    integer, allocatable :: j
  end type

  type t2
    class(t0), allocatable :: k
  end type t2

contains

  ! (1) simple allocatable scalars
  subroutine a
    integer, allocatable :: m
    allocate (m)
    m = 42
  end subroutine

  ! (2) allocatable scalar CLASS variables
  subroutine b
    class(t0), allocatable :: m
    allocate (t0 :: m)
    m%i = 43
  end subroutine

  ! (3) allocatable scalar components
  subroutine c
    type(t1) :: m
    allocate (m%j)
    m%j = 44
  end subroutine

  ! (4) allocatable scalar CLASS components
  subroutine d
    type(t2) :: m
    allocate (t0 :: m%k)
    m%k%i = 45
  end subroutine

end module 


! { dg-final { scan-tree-dump-times "__builtin_free" 4 "original" } }
! { dg-final { cleanup-tree-dump "original" } }