xref: /llvm-project/flang/test/Semantics/deallocate05.f90 (revision fb792ebaf2114ad11d673cf891ae560e2e604711)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Check for semantic errors in DEALLOCATE statements
3
4Module share
5  Real, Pointer :: rp
6End Module share
7
8Program deallocatetest
9Use share
10
11INTEGER, PARAMETER :: maxvalue=1024
12
13Type dt
14  Integer :: l = 3
15End Type
16Type t
17  Type(dt) :: p
18End Type
19
20Type(t),Allocatable :: x(:)
21
22Real :: r
23Integer :: s
24Integer, Parameter :: const_s = 13
25Integer :: e
26Integer :: pi
27Character(256) :: ee
28Procedure(Real) :: prp
29
30Allocate(rp)
31Deallocate(rp)
32
33Allocate(x(3))
34
35!ERROR: Component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
36Deallocate(x(2)%p)
37
38!ERROR: Name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
39Deallocate(pi)
40
41!ERROR: Component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
42!ERROR: Name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
43Deallocate(x(2)%p, pi)
44
45!ERROR: Name in DEALLOCATE statement must be a variable name
46Deallocate(prp)
47
48!ERROR: Name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
49!ERROR: Name in DEALLOCATE statement must be a variable name
50Deallocate(pi, prp)
51
52!ERROR: Name in DEALLOCATE statement must be a variable name
53Deallocate(maxvalue)
54
55!ERROR: Component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
56Deallocate(x%p)
57
58!ERROR: STAT may not be duplicated in a DEALLOCATE statement
59Deallocate(x, stat=s, stat=s)
60!ERROR: STAT variable 'const_s' is not definable
61!BECAUSE: '13_4' is not a variable or pointer
62Deallocate(x, stat=const_s)
63!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
64Deallocate(x, errmsg=ee, errmsg=ee)
65!ERROR: STAT may not be duplicated in a DEALLOCATE statement
66Deallocate(x, stat=s, errmsg=ee, stat=s)
67!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
68Deallocate(x, stat=s, errmsg=ee, errmsg=ee)
69
70End Program deallocatetest
71