Debian Codegraph @

gcc/testsuite/gfortran.dg/int_range_io_1.f90

raw
1 ! { dg-do run }
2 ! { dg-options "-fno-range-check" }
3 ! PR 52428 Read IO of integers near the end of range. Note that we
4 ! support the two's complement representation even though the Fortran
5 ! numerical model has a symmetric range. (The -fno-range-check option
6 ! is needed to allow the -2147483648 literal.)
7 program int_range
8 implicit none
9 character(25) :: inputline = "-2147483648"
10 integer(4) :: test
11 integer :: st
12
13 read(inputline,100) test
14 100 format(1i11)
15 if (test /= -2147483648) STOP 1
16 inputline(1:1) = " "
17 read(inputline, 100, iostat=st) test
18 if (st == 0) STOP 2
19 inputline(11:11) = "7"
20 read(inputline, 100) test
21 if (test /= 2147483647) STOP 3
22
23 ! Same as above but with list-formatted IO
24 inputline = "-2147483648"
25 read(inputline, *) test
26 if (test /= -2147483648) STOP 4
27 inputline(1:1) = " "
28 read(inputline, *, iostat=st) test
29 if (st == 0) STOP 5
30 inputline(11:11) = "7"
31 read(inputline, *) test
32 if (test /= 2147483647) STOP 6
33
34 end program int_range