Debian Codegraph @

gcc/testsuite/gfortran.dg/bounds_check_fail_5.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fcheck=bounds -g -fdump-tree-original" }
3 ! { dg-output "At line 13 .*" }
4 ! { dg-shouldfail "Array bound mismatch for dimension 1 of array 'ivec' (2/3)" }
5 !
6 ! PR fortran/31059 - runtime bounds-checking in presence of array constructors
7
8 program p
9 integer :: jvec(3) = [1,2,3]
10 integer, allocatable :: ivec(:), kvec(:), lvec(:), mvec(:), nvec(:)
11 ivec = [1,2] ! (re)allocation
12 kvec = [4,5,6] ! (re)allocation
13 ivec(:) = [4,5,6] ! runtime error (->dump)
14 ! not reached ...
15 print *, jvec + [1,2,3] ! OK & no check generated
16 print *, [4,5,6] + jvec ! OK & no check generated
17 print *, lvec + [1,2,3] ! check generated (->dump)
18 print *, [4,5,6] + mvec ! check generated (->dump)
19 nvec(:) = jvec ! check generated (->dump)
20 end
21
22 ! { dg-final { scan-tree-dump-times "Array bound mismatch " 4 "original" } }
23 ! { dg-final { scan-tree-dump-times "Array bound mismatch .*ivec" 1 "original" } }
24 ! { dg-final { scan-tree-dump-times "Array bound mismatch .*lvec" 1 "original" } }
25 ! { dg-final { scan-tree-dump-times "Array bound mismatch .*mvec" 1 "original" } }
26 ! { dg-final { scan-tree-dump-times "Array bound mismatch .*nvec" 1 "original" } }