summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.fortran-torture/execute/allocate.f90
blob: 61f717da7bc9dd7ee609d6c526c564db843c2020 (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
! Test allocation and deallocation.
program test_allocate
  call t1 (.true.)
  call t1 (.false.)
  call t2
contains

! Implicit deallocation and saved aloocated variables.
subroutine t1(first)
  real, allocatable, save :: p(:)
  real, allocatable :: q(:)
  logical first

  if (first) then
    if (allocated (p)) call abort ()
  else
    if (.not. allocated (p)) call abort ()
  end if
  if (allocated (q)) call abort ()

  if (first) then
    allocate (p(5))
  else
    deallocate (p)
  end if
  allocate (q(5))
end subroutine

! Explicit deallocation.
subroutine t2()
  real, allocatable :: r(:)

  allocate (r(5))
  pr = 1.0
  deallocate (r)
  if (allocated(r)) call abort ()
end subroutine
end program