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
)
6 function return_allocatable()
7 integer, allocatable
:: return_allocatable(:)
12 integer, allocatable
:: alloc(:)
17 real, allocatable
:: coarray_alloc
[:]
18 real, allocatable
:: coarray_alloc_array(:)[:]
22 integer :: not_alloc(100)
23 real, allocatable
:: x_alloc
24 character(:), allocatable
:: char_alloc(:)
25 type(t1
) :: dt_not_alloc(100)
26 type(t1
), allocatable
:: dt_alloc(:)
28 real, allocatable
:: coarray_alloc
[:, :]
29 real, allocatable
:: coarray_alloc_array(:)[:, :]
30 real :: coarray_not_alloc(:)[*]
32 type(t2
) :: t2_not_alloc
36 print *, allocated(x_alloc
)
37 print *, allocated(char_alloc
)
38 print *, allocated(dt_alloc
)
39 print *, allocated(dt_not_alloc(3)%alloc
)
40 print *, allocated(dt_alloc(3)%alloc
)
41 print *, allocated(coarray_alloc
)
42 print *, allocated(coarray_alloc
[2,3])
43 print *, allocated(t2_not_alloc
%coarray_alloc
)
44 print *, allocated(t2_not_alloc
%coarray_alloc
[2])
46 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
47 print *, allocated(not_alloc
)
48 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
49 print *, allocated(dt_not_alloc
)
50 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
51 print *, allocated(dt_alloc
%not_alloc
)
52 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
53 print *, allocated(char_alloc(:))
54 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
55 print *, allocated(char_alloc(1)(1:10))
56 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
57 print *, allocated(coarray_alloc_array(1:10))
58 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
59 print *, allocated(coarray_alloc_array(1:10)[2,2])
60 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
61 print *, allocated(t2_not_alloc
%coarray_alloc_array(1))
62 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
63 print *, allocated(t2_not_alloc
%coarray_alloc_array(1)[2])
64 !ERROR: Argument of ALLOCATED() must be an ALLOCATABLE object or component
65 print *, allocated(return_allocatable())