1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror
2 ! Check out-of-range subscripts
4 integer, parameter :: n(2) = [1, 2]
6 !ERROR: DATA statement designator 'a(0_8)' is out of range
7 !ERROR: DATA statement designator 'a(11_8)' is out of range
8 data a(0)/0./, a(10+1)/0./
9 !ERROR: Subscript 0 is less than lower bound 1 for dimension 1 of array
11 !ERROR: Subscript 0 is less than lower bound 1 for dimension 1 of array
13 !ERROR: Subscript 11 is greater than upper bound 10 for dimension 1 of array
15 !ERROR: Subscript 11 is greater than upper bound 10 for dimension 1 of array
17 !ERROR: Subscript value (0) is out of range on dimension 1 in reference to a constant array value
19 !ERROR: Subscript value (3) is out of range on dimension 1 in reference to a constant array value
21 print *, a(1:12:3) ! ok
22 !ERROR: Subscript 13 is greater than upper bound 10 for dimension 1 of array
24 print *, a(10:-1:-3) ! ok
25 !ERROR: Subscript -2 is less than lower bound 1 for dimension 1 of array
27 print *, a(-1:-2) ! empty section is ok
28 print *, a(0:11:-1) ! empty section is ok
29 !ERROR: Subscript 0 is less than lower bound 1 for dimension 1 of array
30 print *, a(0:0:unknown
) ! lower==upper, can ignore stride
31 !ERROR: Subscript 11 is greater than upper bound 10 for dimension 1 of array
32 print *, a(11:11:unknown
) ! lower==upper, can ignore stride