2009-10-05 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / nan_3.f90
blob0a46fdb6ce4e5359c4d403c81f2a44b45f2a6f23
1 ! { dg-do run }
2 ! { dg-options "-fno-range-check" }
3 ! { dg-add-options ieee }
4 ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
6 ! PR fortran/34319
8 ! Check support of INF/NaN for I/O.
10 program main
11 implicit none
12 real :: r
13 complex :: z
14 character(len=30) :: str
16 str = "nan"
17 read(str,*) r
18 if (.not.isnan(r)) call abort()
19 str = "(nan,4.0)"
20 read(str,*) z
21 if (.not.isnan(real(z)) .or. aimag(z) /= 4.0) call abort()
22 str = "(7.0,nan)"
23 read(str,*) z
24 if (.not.isnan(aimag(z)) .or. real(z) /= 7.0) call abort()
26 str = "inFinity"
27 read(str,*) r
28 if (r <= huge(r)) call abort()
29 str = "(+inFinity,4.0)"
30 read(str,*) z
31 if ((real(z) <= huge(r)) .or. aimag(z) /= 4.0) call abort()
32 str = "(7.0,-inFinity)"
33 read(str,*) z
34 if ((aimag(z) >= -huge(r)) .or. real(z) /= 7.0) call abort()
36 str = "inf"
37 read(str,*) r
38 if (r <= huge(r)) call abort()
39 str = "(+inf,4.0)"
40 read(str,*) z
41 if ((real(z) <= huge(r)) .or. aimag(z) /= 4.0) call abort()
42 str = "(7.0,-inf)"
43 read(str,*) z
44 if ((aimag(z) >= -huge(r)) .or. real(z) /= 7.0) call abort()
46 end program main