xref: /llvm-project/flang/test/Semantics/deallocate01.f90 (revision f2360e1156d086ac5ac58d7f29449adf9e75d716)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Test that DEALLOCATE works
3
4INTEGER, PARAMETER :: maxvalue=1024
5
6Type dt
7  Integer :: l = 3
8End Type
9Type t
10  Type(dt),Pointer :: p
11End Type
12
13Type(t),Allocatable :: x(:)
14Type(t),Pointer :: y(:)
15Type(t),Pointer :: z
16Integer :: s
17CHARACTER(256) :: e
18
19Integer, Pointer :: pi
20
21Allocate(pi)
22Allocate(x(3))
23
24Deallocate(x(2)%p)
25
26Deallocate(y(2)%p)
27
28Deallocate(pi)
29
30Deallocate(z%p)
31
32!ERROR: An allocatable or pointer component reference must be applied to a scalar base
33Deallocate(x%p, stat=s, errmsg=e)
34Deallocate(x, errmsg=e)
35Deallocate(x, stat=s)
36
37Deallocate(y, stat=s, errmsg=e)
38Deallocate(y, errmsg=e)
39Deallocate(y, stat=s)
40
41Deallocate(z, stat=s, errmsg=e)
42Deallocate(z, errmsg=e)
43Deallocate(z, stat=s)
44
45Deallocate(z, y, stat=s, errmsg=e)
46Deallocate(z, y, errmsg=e)
47Deallocate(z, y, stat=s)
48
49End Program
50