brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · c366060 Raw
49 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror2! Check out-of-range subscripts3subroutine subr(da)4  real a(10), da(2,1), empty(1:0,1)5  integer, parameter :: n(2) = [1, 2]6  integer unknown7  !ERROR: DATA statement designator 'a(0_8)' is out of range8  !ERROR: DATA statement designator 'a(11_8)' is out of range9  data a(0)/0./, a(10+1)/0./10  !ERROR: subscript 0 is less than lower bound 1 for dimension 1 of array11  print *, a(0)12  !ERROR: subscript 0 is less than lower bound 1 for dimension 1 of array13  print *, a(1-1)14  !ERROR: subscript 11 is greater than upper bound 10 for dimension 1 of array15  print *, a(11)16  !ERROR: subscript 11 is greater than upper bound 10 for dimension 1 of array17  print *, a(10+1)18  !ERROR: Subscript value (0) is out of range on dimension 1 in reference to a constant array value19  print *, n(0)20  !ERROR: Subscript value (3) is out of range on dimension 1 in reference to a constant array value21  print *, n(4-1)22  print *, a(1:12:3) ! ok23  !ERROR: subscript 13 is greater than upper bound 10 for dimension 1 of array24  print *, a(1:13:3)25  print *, a(10:-1:-3) ! ok26  !ERROR: subscript -2 is less than lower bound 1 for dimension 1 of array27  print *, a(10:-2:-3)28  print *, a(-1:-2) ! empty section is ok29  print *, a(0:11:-1) ! empty section is ok30  !ERROR: subscript 0 is less than lower bound 1 for dimension 1 of array31  print *, a(0:0:unknown) ! lower==upper, can ignore stride32  !ERROR: subscript 11 is greater than upper bound 10 for dimension 1 of array33  print *, a(11:11:unknown) ! lower==upper, can ignore stride34  !ERROR: subscript 0 is less than lower bound 1 for dimension 1 of array35  print *, da(0,1)36  !ERROR: subscript 3 is greater than upper bound 2 for dimension 1 of array37  print *, da(3,1)38  !ERROR: subscript 0 is less than lower bound 1 for dimension 2 of array39  print *, da(1,0)40  !WARNING: subscript 2 is greater than upper bound 1 for dimension 2 of array41  print *, da(1,2)42  print *, empty([(j,j=1,0)],1) ! ok43  print *, empty(1:0,1) ! ok44  print *, empty(:,1) ! ok45  print *, empty(i:j,k) ! ok46  !WARNING: Empty array dimension 1 should not be subscripted as an element or non-empty array section [-Wsubscripted-empty-array]47  print *, empty(i,1)48end49