[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / allocated.f90
blob82ce7ca7bdb9f80539cdf89b2708c818102899ed
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)
5 interface
6 function return_allocatable()
7 integer, allocatable :: return_allocatable(:)
8 end function
9 end interface
11 type :: t1
12 integer, allocatable :: alloc(:)
13 integer :: not_alloc
14 end type
16 type :: t2
17 real, allocatable :: coarray_alloc[:]
18 real, allocatable :: coarray_alloc_array(:)[:]
19 end type
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
35 ! OK
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())
66 end subroutine