1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Tests for the ALLOCATED() intrinsic
3 subroutine alloc(coarray_alloc
, coarray_not_alloc
, t2_not_alloc
, &
7 function return_allocatable()
8 integer, allocatable
:: return_allocatable(:)
13 integer, allocatable
:: alloc(:)
18 real, allocatable
:: coarray_alloc
[:]
19 real, allocatable
:: coarray_alloc_array(:)[:]
23 integer :: not_alloc(100)
24 real, allocatable
:: x_alloc
25 character(:), allocatable
:: char_alloc(:)
26 type(t1
) :: dt_not_alloc(100)
27 type(t1
), allocatable
:: dt_alloc(:)
29 real, allocatable
:: coarray_alloc
[:, :]
30 real, allocatable
:: coarray_alloc_array(:)[:, :]
31 real :: coarray_not_alloc(:)[*]
33 type(t2
) :: t2_not_alloc
34 real, allocatable
:: assumedRank(..)
38 print *, allocated(x_alloc
)
39 print *, allocated(char_alloc
)
40 print *, allocated(dt_alloc
)
41 print *, allocated(dt_not_alloc(3)%alloc
)
42 print *, allocated(dt_alloc(3)%alloc
)
43 print *, allocated(coarray_alloc
)
44 print *, allocated(coarray_alloc
[2,3])
45 print *, allocated(t2_not_alloc
%coarray_alloc
)
46 print *, allocated(t2_not_alloc
%coarray_alloc
[2])
47 print *, allocated(assumedRank
)
48 select
rank (assumedRank
)
50 print *, allocated(scalar
=assumedRank
)
52 print *, allocated(array
=assumedRank
)
55 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
56 print *, allocated(not_alloc
)
57 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
58 print *, allocated(dt_not_alloc
)
59 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
60 print *, allocated(dt_alloc
%not_alloc
)
61 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
62 print *, allocated(char_alloc(:))
63 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
64 print *, allocated(char_alloc(1)(1:10))
65 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
66 print *, allocated(coarray_alloc_array(1:10))
67 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
68 print *, allocated(coarray_alloc_array(1:10)[2,2])
69 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
70 print *, allocated(t2_not_alloc
%coarray_alloc_array(1))
71 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
72 print *, allocated(t2_not_alloc
%coarray_alloc_array(1)[2])
73 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
74 print *, allocated(return_allocatable())