1 ! RUN: %python %S/test_errors.py %s %flang_fc1
9 !ERROR: Assignment to constant 'x%k' is not allowed
11 !ERROR: Assignment to constant 'x%l' is not allowed
17 !ERROR: A dummy argument may not also be a named constant
18 real, parameter :: x
= 0.0
19 real, parameter :: a(*) = [1, 2, 3]
20 character, parameter :: c(2) = "ab"
22 !ERROR: Assignment to constant 'x' is not allowed
25 !ERROR: Left-hand side of assignment is not definable
26 !BECAUSE: 'a' is not a variable
28 !ERROR: Left-hand side of assignment is not definable
29 !BECAUSE: 'a' is not a variable
31 !ERROR: Left-hand side of assignment is not definable
32 !BECAUSE: 'c' is not a variable
43 type(t
), parameter :: y
= t([1,2], 3)
46 !ERROR: Left-hand side of assignment is not definable
47 !BECAUSE: 'y' is not a variable
50 !ERROR: Assignment to constant 'y%b' is not allowed
61 type(t
), intent(in
) :: x
62 character(10), intent(in
) :: c
64 !ERROR: Left-hand side of assignment is not definable
65 !BECAUSE: 'x' is an INTENT(IN) dummy argument
67 !ERROR: Left-hand side of assignment is not definable
68 !BECAUSE: 'x' is an INTENT(IN) dummy argument
70 !ERROR: Left-hand side of assignment is not definable
71 !BECAUSE: 'c' is an INTENT(IN) dummy argument
84 type(t
), protected
:: b
90 !ERROR: Left-hand side of assignment is not definable
91 !BECAUSE: 'y' is protected in this scope
93 !ERROR: No explicit type declared for 'z'
95 !ERROR: Left-hand side of assignment is not definable
96 !BECAUSE: 'b' is protected in this scope
104 !ERROR: Assumed-size array 'x' must have explicit final subscript upper bound value
106 !ERROR: Whole assumed-size array 'x' may not appear here without subscripts
118 !ERROR: Whole assumed-size array 'x' may not appear here without subscripts
124 integer :: a(10), v(10)
125 a(v(:)) = 1 ! vector subscript is ok
129 !ERROR: Assignment to procedure 's8' is not allowed
133 real function f9() result(r
)
134 !ERROR: Assignment to procedure 'f9' is not allowed
140 !ERROR: Assignment to procedure 'f9a' is not allowed
145 !ERROR: No explicit type declared for dummy argument 'n'
149 a(1:n
) = 0.0 ! should not get a second error here
155 !ERROR: Function call must have argument list
157 !ERROR: Subroutine name is not allowed here
162 type dType(l1
, k1
, l2
, k2
)
170 subroutine sub(arg1
, arg2
, arg3
)
172 type(dType(arg1
, 2, *, 4)) :: arg2
173 type(dType(*, 2, arg1
, 4)) :: arg3
174 type(dType(1, 2, 3, 4)) :: local1
175 type(dType(1, 2, 3, 4)) :: local2
176 type(dType(1, 2, arg1
, 4)) :: local3
177 type(dType(9, 2, 3, 4)) :: local4
178 type(dType(1, 9, 3, 4)) :: local5
185 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(dtype(k1=2_4,k2=4_4,l1=1_4,l2=3_4)) and TYPE(dtype(k1=2_4,k2=4_4,l1=9_4,l2=3_4))
186 local1
= local4
! mismatched constant KIND type parameter
187 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(dtype(k1=2_4,k2=4_4,l1=1_4,l2=3_4)) and TYPE(dtype(k1=9_4,k2=4_4,l1=1_4,l2=3_4))
188 local1
= local5
! mismatched constant LEN type parameter
193 interface assignment(=)
194 procedure
:: cToR
, cToRa
, cToI
200 !ERROR: Defined assignment in WHERE must be elemental, but 'ctora' is not
202 where ([1==1]) n
='*' ! fine
204 !ERROR: The mask or variable must not be scalar
206 !ERROR: Defined assignment in WHERE must be elemental, but 'ctor' is not
207 !ERROR: The mask or variable must not be scalar
209 !ERROR: The mask or variable must not be scalar
211 !ERROR: The mask or variable must not be scalar
213 !ERROR: Defined assignment in WHERE must be elemental, but 'ctor' is not
214 !ERROR: The mask or variable must not be scalar
216 !ERROR: The mask or variable must not be scalar
219 !ERROR: Defined assignment in WHERE must be elemental, but 'ctor' is not
220 !ERROR: The mask or variable must not be scalar
222 !ERROR: The mask or variable must not be scalar
229 subroutine cToR(x
, c
)
230 real, intent(out
) :: x
231 character, intent(in
) :: c
233 subroutine cToRa(x
, c
)
234 real, intent(out
) :: x(:)
235 character, intent(in
) :: c
237 elemental
subroutine cToI(n
, c
)
238 integer, intent(out
) :: n
239 character, intent(in
) :: c
245 integer, pointer :: p
247 procedure definedAsst1
248 generic
:: assignment(=) => definedAsst1
251 integer, pointer :: p
253 interface assignment(=)
254 module procedure definedAsst2
257 integer, pointer :: p
260 pure
subroutine definedAsst1(lhs
,rhs
)
261 class(t1
), intent(in out
) :: lhs
262 class(t1
), intent(in
) :: rhs
264 pure
subroutine definedAsst2(lhs
,rhs
)
265 type(t2
), intent(out
) :: lhs
266 type(t2
), intent(in
) :: rhs
268 pure
subroutine test(y1
,y2
,y3
)
270 type(t1
), intent(in
) :: y1
272 type(t2
), intent(in
) :: y2
274 type(t3
), intent(in
) :: y3
275 x1
= y1
! fine due to not being intrinsic assignment
276 x2
= y2
! fine due to not being intrinsic assignment
277 !ERROR: A pure subprogram may not copy the value of 'y3' because it is an INTENT(IN) dummy argument and has the POINTER potential subobject component '%p'