1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 !Tests for SELECT RANK Construct(R1148)
6 integer, dimension(10:30, 10:20, -1:20) :: x
7 integer, parameter :: y(*) = [1,2,3,4]
8 integer, dimension(5) :: z
9 integer, allocatable
:: a(:)
25 print *, "PRINT RANK 0"
27 print *, "PRINT RANK 1"
31 subroutine CALL_ME9(x
)
36 print *, "PRINT RANK 1"
37 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == (1+0)))
42 subroutine CALL_ME2(x
)
46 !ERROR: Selector 'y' is not an assumed-rank array variable
49 print *, "PRINT RANK 0"
51 print *, "PRINT RANK 1"
56 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 0)) ! will fail when RANK(x) is not zero here
60 subroutine CALL_ME3(x
)
64 !ERROR: The value of the selector must be between zero and 15
66 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 16))
70 subroutine CALL_ME4(x
)
76 !ERROR: Not more than one of the selectors of SELECT RANK statement may be DEFAULT
84 subroutine CALL_ME5(x
)
89 print *, "PRINT RANK 0"
90 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 0))
92 print *, "PRINT RANK 1"
93 !ERROR: Same rank value (0) not allowed more than once
96 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 0))
98 !ERROR: Same rank value (2) not allowed more than once
103 subroutine CALL_ME6(x
)
109 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 3))
110 !ERROR: The value of the selector must be between zero and 15
112 print *, "rank: negative"
113 !ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
114 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == -1))
118 subroutine CALL_ME7(arg
)
121 integer, dimension(..), pointer :: arg
122 integer, pointer :: arg2
124 !ERROR: RANK (*) cannot be used when selector is POINTER or ALLOCATABLE
129 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(arg
) == 1))
132 !ERROR: Selector 'arg2' is not an assumed-rank array variable
135 print *,"This would lead to crash when saveSelSymbol has std::nullptr"
142 subroutine CALL_ME8(x
)
147 print *, "Now it's rank 2 "
149 print *, "Going for another rank"
150 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 1))
151 !ERROR: Not more than one of the selectors of SELECT RANK statement may be '*'
153 print *, "This is Wrong"
157 subroutine CALL_ME10(x
)
159 integer:: x(..), a
=10,b
=20,j
160 integer, dimension(5) :: arr
= (/1,2,3,4,5/),brr
161 integer :: const_variable
=10
162 integer, pointer :: ptr
,nullptr
=>NULL()
164 character(len
= 50) :: title
166 type(derived
) :: obj1
170 print *, "Now it's rank 2 "
172 print *, "Going for a other rank"
173 !ERROR: Not more than one of the selectors of SELECT RANK statement may be '*'
175 print *, "This is Wrong"
178 !ERROR: Selector 'brr' is not an assumed-rank array variable
179 SELECT
RANK(ptr
=>brr
)
180 !ERROR: Must be a constant value
182 print *, "PRINT RANK 3"
183 !j = INT(0, KIND=MERGE(KIND(0), -1, RANK(ptr) == 1))
184 !ERROR: Must be a constant value
186 print *, "PRINT RANK 3"
189 !ERROR: Selector 'x(1) + x(2)' is not an assumed-rank array variable
190 SELECT
RANK (x(1) + x(2))
194 !ERROR: Selector 'x(1)' is not an assumed-rank array variable
199 !ERROR: Selector 'x(1:2)' is not an assumed-rank array variable
204 !ERROR: 'x' is not an object of derived type
205 SELECT
RANK(x(1)%x(2))
209 !ERROR: Selector 'obj1%title' is not an assumed-rank array variable
210 SELECT
RANK(obj1
%title
)
214 !ERROR: Selector 'arr(1:2)+ arr(4:5)' is not an assumed-rank array variable
215 SELECT
RANK(arr(1:2)+ arr(4:5))
221 PRINT *, "PRINT RANK 3"
222 !ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
223 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(ptr
) == 0))
225 PRINT *, "PRINT RANK 1"
226 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(ptr
) == 1))
229 subroutine CALL_ME_TYPES(x
)
233 !ERROR: Must have INTEGER type, but is LOGICAL(4)
235 !ERROR: Must have INTEGER type, but is REAL(4)
237 !ERROR: Must be a constant value
239 !ERROR: Must have INTEGER type, but is CHARACTER(KIND=1,LEN=6_8)
243 subroutine CALL_SHAPE(x
)
247 integer, pointer :: ptr
251 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 1))
254 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 3))
256 SELECT
RANK(ptr
=> x
)
259 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(ptr
) == 1))
262 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(ptr
) == 3))