Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / deallocate05.f90
blobbdc6998094064f705b3ca1a9d4fda6cb9652342e
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Check for semantic errors in DEALLOCATE statements
4 Module share
5 Real, Pointer :: rp
6 End Module share
8 Program deallocatetest
9 Use share
11 INTEGER, PARAMETER :: maxvalue=1024
13 Type dt
14 Integer :: l = 3
15 End Type
16 Type t
17 Type(dt) :: p
18 End Type
20 Type(t),Allocatable :: x(:)
22 Real :: r
23 Integer :: s
24 Integer, Parameter :: const_s = 13
25 Integer :: e
26 Integer :: pi
27 Character(256) :: ee
28 Procedure(Real) :: prp
30 Allocate(rp)
31 Deallocate(rp)
33 Allocate(x(3))
35 !ERROR: Component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
36 Deallocate(x(2)%p)
38 !ERROR: Name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
39 Deallocate(pi)
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
43 Deallocate(x(2)%p, pi)
45 !ERROR: Name in DEALLOCATE statement must be a variable name
46 Deallocate(prp)
48 !ERROR: Name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
49 !ERROR: Name in DEALLOCATE statement must be a variable name
50 Deallocate(pi, prp)
52 !ERROR: Name in DEALLOCATE statement must be a variable name
53 Deallocate(maxvalue)
55 !ERROR: Component in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute
56 Deallocate(x%p)
58 !ERROR: STAT may not be duplicated in a DEALLOCATE statement
59 Deallocate(x, stat=s, stat=s)
60 !ERROR: STAT variable 'const_s' is not definable
61 !BECAUSE: '13_4' is not a variable or pointer
62 Deallocate(x, stat=const_s)
63 !ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
64 Deallocate(x, errmsg=ee, errmsg=ee)
65 !ERROR: STAT may not be duplicated in a DEALLOCATE statement
66 Deallocate(x, stat=s, errmsg=ee, stat=s)
67 !ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
68 Deallocate(x, stat=s, errmsg=ee, errmsg=ee)
70 End Program deallocatetest