Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / lcobound.f90
blob8feb496e1984e1264f31dcc4da55ed3310530e07
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Check for semantic errors in lcobound() function references
4 program lcobound_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 :: lcobounds(:)
15 !___ standard-conforming statement with no optional arguments present ___
16 lcobounds = lcobound(scalar_coarray)
17 lcobounds = lcobound(array_coarray)
18 lcobounds = lcobound(coarray_corank3)
19 lcobounds = lcobound(logical_coarray)
20 lcobounds = lcobound(coarray=scalar_coarray)
22 !___ standard-conforming statements with optional dim argument present ___
23 n = lcobound(scalar_coarray, 1)
24 n = lcobound(coarray_corank3, 1)
25 n = lcobound(coarray_corank3, 3)
26 n = lcobound(scalar_coarray, const_in_range_dim)
27 n = lcobound(logical_coarray, const_in_range_dim)
28 n = lcobound(scalar_coarray, dim=1)
29 n = lcobound(coarray=scalar_coarray, dim=1)
30 n = lcobound( dim=1, coarray=scalar_coarray)
32 !___ standard-conforming statements with optional kind argument present ___
33 n = lcobound(scalar_coarray, 1, c_int32_t)
35 n = lcobound(scalar_coarray, 1, kind=c_int32_t)
37 n = lcobound(scalar_coarray, dim=1, kind=c_int32_t)
38 n = lcobound(scalar_coarray, kind=c_int32_t, dim=1)
40 lcobounds = lcobound(scalar_coarray, kind=c_int32_t)
42 lcobounds = lcobound(coarray=scalar_coarray, kind=c_int32_t)
43 lcobounds = lcobound(kind=c_int32_t, coarray=scalar_coarray)
45 n = lcobound(coarray=scalar_coarray, dim=1, kind=c_int32_t)
46 n = lcobound(dim=1, coarray=scalar_coarray, kind=c_int32_t)
47 n = lcobound(kind=c_int32_t, coarray=scalar_coarray, dim=1)
48 n = lcobound(dim=1, kind=c_int32_t, coarray=scalar_coarray)
49 n = lcobound(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 = lcobound(scalar_coarray, dim=0)
56 !ERROR: DIM=0 dimension is out of range for coarray with corank 3
57 n = lcobound(coarray_corank3, dim=0)
59 !ERROR: DIM=-1 dimension is out of range for coarray with corank 1
60 n = lcobound(scalar_coarray, dim=-1)
62 !ERROR: DIM=2 dimension is out of range for coarray with corank 1
63 n = lcobound(array_coarray, dim=2)
65 !ERROR: DIM=2 dimension is out of range for coarray with corank 1
66 n = lcobound(array_coarray, 2)
68 !ERROR: DIM=4 dimension is out of range for coarray with corank 3
69 n = lcobound(coarray_corank3, dim=4)
71 !ERROR: DIM=4 dimension is out of range for coarray with corank 3
72 n = lcobound(dim=4, coarray=coarray_corank3)
74 !ERROR: DIM=5 dimension is out of range for coarray with corank 3
75 n = lcobound(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 = lcobound(scalar_coarray)
80 !ERROR: missing mandatory 'coarray=' argument
81 n = lcobound(dim=i)
83 !ERROR: Actual argument for 'dim=' has bad type 'LOGICAL(4)'
84 n = lcobound(scalar_coarray, non_integer)
86 !ERROR: Actual argument for 'dim=' has bad type 'LOGICAL(4)'
87 n = lcobound(scalar_coarray, dim=non_integer)
89 !ERROR: Actual argument for 'kind=' has bad type 'LOGICAL(4)'
90 lcobounds = lcobound(scalar_coarray, kind=const_non_integer)
92 !ERROR: Actual argument for 'kind=' has bad type 'LOGICAL(4)'
93 n = lcobound(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 lcobounds = lcobound(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 = lcobound(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 = lcobound(scalar_coarray, 1, non_constant)
104 !ERROR: missing mandatory 'coarray=' argument
105 n = lcobound(dim=i, kind=c_int32_t)
107 n = lcobound(coarray=scalar_coarray, i)
109 !ERROR: missing mandatory 'coarray=' argument
110 lcobounds = lcobound()
112 !ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'lcobound'
113 lcobounds = lcobound(3.4)
115 !ERROR: keyword argument to intrinsic 'lcobound' was supplied positionally by an earlier actual argument
116 n = lcobound(scalar_coarray, 1, coarray=scalar_coarray)
118 !ERROR: too many actual arguments for intrinsic 'lcobound'
119 n = lcobound(scalar_coarray, i, c_int32_t, 0)
121 !ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'lcobound'
122 lcobounds = lcobound(coarray=non_coarray)
124 !ERROR: 'coarray=' argument must have corank > 0 for intrinsic 'lcobound'
125 n = lcobound(coarray=non_coarray, dim=1)
127 !ERROR: 'dim=' argument has unacceptable rank 1
128 n = lcobound(scalar_coarray, array )
130 !ERROR: unknown keyword argument to intrinsic 'lcobound'
131 lcobounds = lcobound(c=scalar_coarray)
133 !ERROR: unknown keyword argument to intrinsic 'lcobound'
134 n = lcobound(scalar_coarray, dims=i)
136 !ERROR: unknown keyword argument to intrinsic 'lcobound'
137 n = lcobound(scalar_coarray, i, kinds=c_int32_t)
139 !ERROR: repeated keyword argument to intrinsic 'lcobound'
140 n = lcobound(scalar_coarray, dim=1, dim=2)
142 !ERROR: repeated keyword argument to intrinsic 'lcobound'
143 lcobounds = lcobound(coarray=scalar_coarray, coarray=array_coarray)
145 !ERROR: repeated keyword argument to intrinsic 'lcobound'
146 lcobounds = lcobound(scalar_coarray, kind=c_int32_t, kind=c_int64_t)
148 end program lcobound_tests