2014-07-12 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / int_range_io_1.f90
blobde1fdb81304e6735c60e4e27b6fba4b00bb4d6a3
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
13 read(inputline,100) test
14 100 format(1i11)
15 if (test /= -2147483648) call abort
16 inputline(1:1) = " "
17 read(inputline, 100, iostat=st) test
18 if (st == 0) call abort
19 inputline(11:11) = "7"
20 read(inputline, 100) test
21 if (test /= 2147483647) call abort
23 ! Same as above but with list-formatted IO
24 inputline = "-2147483648"
25 read(inputline, *) test
26 if (test /= -2147483648) call abort
27 inputline(1:1) = " "
28 read(inputline, *, iostat=st) test
29 if (st == 0) call abort
30 inputline(11:11) = "7"
31 read(inputline, *) test
32 if (test /= 2147483647) call abort
34 end program int_range