[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / ucobound.f90
blobda9f995f1a97bcb531bdcd6e625b4cb1911b307e
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Check for semantic errors in ucobound() function references
4 program ucobound_tests
5 use iso_c_binding, only : c_int32_t, c_int64_t
6 implicit none
8 integer n, i, array(1), non_coarray(1), scalar_coarray[*], array_coarray(1)[*], non_constant, scalar
9 integer, parameter :: const_out_of_range_dim = 5, const_in_range_dim = 1
10 real, allocatable :: coarray_corank3[:,:,:]
11 logical non_integer, logical_coarray[3,*]
12 logical, parameter :: const_non_integer = .true.
13 integer, allocatable :: ucobounds(:)
15 !___ standard-conforming statement with no optional arguments present ___
16 ucobounds = ucobound(scalar_coarray)
17 ucobounds = ucobound(array_coarray)
18 ucobounds = ucobound(coarray_corank3)
19 ucobounds = ucobound(logical_coarray)
20 ucobounds = ucobound(coarray=scalar_coarray)
22 !___ standard-conforming statements with optional dim argument present ___
23 n = ucobound(scalar_coarray, 1)
24 n = ucobound(coarray_corank3, 1)
25 n = ucobound(coarray_corank3, 3)
26 n = ucobound(scalar_coarray, const_in_range_dim)
27 n = ucobound(logical_coarray, const_in_range_dim)
28 n = ucobound(scalar_coarray, dim=1)
29 n = ucobound(coarray=scalar_coarray, dim=1)
30 n = ucobound( dim=1, coarray=scalar_coarray)
32 !___ standard-conforming statements with optional kind argument present ___
33 n = ucobound(scalar_coarray, 1, c_int32_t)
35 n = ucobound(scalar_coarray, 1, kind=c_int32_t)
37 n = ucobound(scalar_coarray, dim=1, kind=c_int32_t)
38 n = ucobound(scalar_coarray, kind=c_int32_t, dim=1)
40 ucobounds = ucobound(scalar_coarray, kind=c_int32_t)
42 ucobounds = ucobound(coarray=scalar_coarray, kind=c_int32_t)
43 ucobounds = ucobound(kind=c_int32_t, coarray=scalar_coarray)
45 n = ucobound(coarray=scalar_coarray, dim=1, kind=c_int32_t)
46 n = ucobound(dim=1, coarray=scalar_coarray, kind=c_int32_t)
47 n = ucobound(kind=c_int32_t, coarray=scalar_coarray, dim=1)
48 n = ucobound(dim=1, kind=c_int32_t, coarray=scalar_coarray)
49 n = ucobound(kind=c_int32_t, dim=1, coarray=scalar_coarray)
51 !___ non-conforming statements ___
53 !ERROR: DIM=0 dimension is out of range for coarray with corank 1
54 n = ucobound(scalar_coarray, dim=0)
56 !ERROR: DIM=0 dimension is out of range for coarray with corank 3
57 n = ucobound(coarray_corank3, dim=0)
59 !ERROR: DIM=-1 dimension is out of range for coarray with corank 1
60 n = ucobound(scalar_coarray, dim=-1)
62 !ERROR: DIM=2 dimension is out of range for coarray with corank 1
63 n = ucobound(array_coarray, dim=2)
65 !ERROR: DIM=2 dimension is out of range for coarray with corank 1
66 n = ucobound(array_coarray, 2)
68 !ERROR: DIM=4 dimension is out of range for coarray with corank 3
69 n = ucobound(coarray_corank3, dim=4)
71 !ERROR: DIM=4 dimension is out of range for coarray with corank 3
72 n = ucobound(dim=4, coarray=coarray_corank3)
74 !ERROR: DIM=5 dimension is out of range for coarray with corank 3
75 n = ucobound(coarray_corank3, const_out_of_range_dim)
77 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)
78 scalar = ucobound(scalar_coarray)
80 !ERROR: missing mandatory 'coarray=' argument
81 n = ucobound(dim=i)
83 !ERROR: Actual argument for 'dim=' has bad type 'LOGICAL(4)'
84 n = ucobound(scalar_coarray, non_integer)
86 !ERROR: Actual argument for 'dim=' has bad type 'LOGICAL(4)'
87 n = ucobound(scalar_coarray, dim=non_integer)
89 !ERROR: Actual argument for 'kind=' has bad type 'LOGICAL(4)'
90 ucobounds = ucobound(scalar_coarray, kind=const_non_integer)
92 !ERROR: Actual argument for 'kind=' has bad type 'LOGICAL(4)'
93 n = ucobound(scalar_coarray, 1, const_non_integer)
95 !ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
96 ucobounds = ucobound(scalar_coarray, kind=non_constant)
98 !ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
99 n = ucobound(scalar_coarray, dim=1, kind=non_constant)
101 !ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
102 n = ucobound(scalar_coarray, 1, non_constant)
104 !ERROR: missing mandatory 'coarray=' argument
105 n = ucobound(dim=i, kind=c_int32_t)
107 n = ucobound(coarray=scalar_coarray, i)
109 !ERROR: missing mandatory 'coarray=' argument
110 ucobounds = ucobound()
112 !ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'ucobound'
113 ucobounds = ucobound(3.4)
115 !ERROR: keyword argument to intrinsic 'ucobound' was supplied positionally by an earlier actual argument
116 n = ucobound(scalar_coarray, 1, coarray=scalar_coarray)
118 !ERROR: too many actual arguments for intrinsic 'ucobound'
119 n = ucobound(scalar_coarray, i, c_int32_t, 0)
121 !ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'ucobound'
122 ucobounds = ucobound(coarray=non_coarray)
124 !ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'ucobound'
125 n = ucobound(coarray=non_coarray, dim=1)
127 !ERROR: 'dim=' argument has unacceptable rank 1
128 n = ucobound(scalar_coarray, array )
130 !ERROR: unknown keyword argument to intrinsic 'ucobound'
131 ucobounds = ucobound(c=scalar_coarray)
133 !ERROR: unknown keyword argument to intrinsic 'ucobound'
134 n = ucobound(scalar_coarray, dims=i)
136 !ERROR: unknown keyword argument to intrinsic 'ucobound'
137 n = ucobound(scalar_coarray, i, kinds=c_int32_t)
139 !ERROR: repeated keyword argument to intrinsic 'ucobound'
140 n = ucobound(scalar_coarray, dim=1, dim=2)
142 !ERROR: repeated keyword argument to intrinsic 'ucobound'
143 ucobounds = ucobound(coarray=scalar_coarray, coarray=array_coarray)
145 !ERROR: repeated keyword argument to intrinsic 'ucobound'
146 ucobounds = ucobound(scalar_coarray, kind=c_int32_t, kind=c_int64_t)
148 end program ucobound_tests