summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/allocate_stat.f90
blob: 7f9eaf58d6d0dffe78ef56dfb949fa9f3f655a80 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
! { dg-do compile }
! PR fortran/32936
!
!
function all_res()
  implicit none
  real, pointer :: gain 
  integer :: all_res
  allocate (gain,STAT=all_res)
  deallocate(gain)
  call bar()
contains
  subroutine bar()
    real, pointer :: gain2
    allocate (gain2,STAT=all_res)
    deallocate(gain2)
  end subroutine bar
end function all_res

function func()
  implicit none
  real, pointer :: gain 
  integer :: all_res2, func
  func = 0
entry all_res2
  allocate (gain,STAT=all_res2)
  deallocate(gain)
contains
  subroutine test
    implicit none
    real, pointer :: gain2
     allocate (gain2,STAT=all_res2)
     deallocate(gain2)
  end subroutine test
end function func

function func2() result(res)
  implicit none
  real, pointer :: gain 
  integer :: res
  allocate (gain,STAT=func2) ! { dg-error "is not a variable" }
  deallocate(gain)
  res = 0
end function func2

subroutine sub()
  implicit none
  interface
    integer function func2()
    end function
  end interface
  real, pointer :: gain 
  integer, parameter :: res = 2
  allocate (gain,STAT=func2) ! { dg-error "is not a variable" }
  deallocate(gain)
end subroutine sub

module test
contains
 function one()
   integer :: one, two
   integer, pointer :: ptr
   allocate(ptr, stat=one)
   if(one == 0) deallocate(ptr)
 entry two
   allocate(ptr, stat=two)
   if(associated(ptr)) deallocate(ptr)
 end function one
 subroutine sub()
   integer, pointer :: p
   allocate(p, stat=one) ! { dg-error "is not a variable" }
   if(associated(p)) deallocate(p)
   allocate(p, stat=two) ! { dg-error "is not a variable" }
   if(associated(p)) deallocate(p)
 end subroutine sub
end module test