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
113 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == -1))
117 subroutine CALL_ME7(arg
)
120 integer, dimension(..), pointer :: arg
121 integer, pointer :: arg2
122 !ERROR: RANK (*) cannot be used when selector is POINTER or ALLOCATABLE
128 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(arg
) == 1))
131 !ERROR: Selector 'arg2' is not an assumed-rank array variable
134 print *,"This would lead to crash when saveSelSymbol has std::nullptr"
141 subroutine CALL_ME8(x
)
146 print *, "Now it's rank 2 "
148 print *, "Going for another rank"
149 !ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
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"
154 !ERROR: 'kind=' argument must be a constant scalar integer whose value is a supported kind for the intrinsic result type
155 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 1))
159 subroutine CALL_ME10(x
)
161 integer:: x(..), a
=10,b
=20,j
162 integer, dimension(5) :: arr
= (/1,2,3,4,5/),brr
163 integer :: const_variable
=10
164 integer, pointer :: ptr
,nullptr
=>NULL()
166 character(len
= 50) :: title
168 type(derived
) :: obj1
172 print *, "Now it's rank 2 "
174 print *, "Going for a other rank"
175 !ERROR: Not more than one of the selectors of SELECT RANK statement may be '*'
177 print *, "This is Wrong"
180 !ERROR: Selector 'brr' is not an assumed-rank array variable
181 SELECT
RANK(ptr
=>brr
)
182 !ERROR: Must be a constant value
184 print *, "PRINT RANK 3"
185 !j = INT(0, KIND=MERGE(KIND(0), -1, RANK(ptr) == 1))
186 !ERROR: Must be a constant value
188 print *, "PRINT RANK 3"
191 !ERROR: Selector 'x(1) + x(2)' is not an assumed-rank array variable
192 SELECT
RANK (x(1) + x(2))
196 !ERROR: Selector 'x(1)' is not an assumed-rank array variable
201 !ERROR: Selector 'x(1:2)' is not an assumed-rank array variable
206 !ERROR: 'x' is not an object of derived type
207 SELECT
RANK(x(1)%x(2))
211 !ERROR: Selector 'obj1%title' is not an assumed-rank array variable
212 SELECT
RANK(obj1
%title
)
216 !ERROR: Selector 'arr(1:2)+ arr(4:5)' is not an assumed-rank array variable
217 SELECT
RANK(arr(1:2)+ arr(4:5))
223 PRINT *, "PRINT RANK 3"
224 !ERROR: 'ptr' is not an object that can appear in an expression
225 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(ptr
) == 0))
227 PRINT *, "PRINT RANK 1"
228 !ERROR: 'ptr' is not an object that can appear in an expression
229 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(ptr
) == 1))
232 subroutine CALL_ME_TYPES(x
)
236 !ERROR: Must have INTEGER type, but is LOGICAL(4)
238 !ERROR: Must have INTEGER type, but is REAL(4)
240 !ERROR: Must be a constant value
242 !ERROR: Must have INTEGER type, but is CHARACTER(KIND=1,LEN=6_8)
246 subroutine CALL_SHAPE(x
)
250 integer, pointer :: ptr
254 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 1))
257 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(x
) == 3))
259 SELECT
RANK(ptr
=> x
)
262 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(ptr
) == 1))
265 j
= INT(0, KIND
=MERGE(KIND(0), -1, RANK(ptr
) == 3))