Debian Codegraph @

gcc/testsuite/gfortran.dg/nan_6.f90

raw
1 ! { dg-do run }
2 ! { dg-add-options ieee }
3 !
4 ! List-directed part of PR fortran/43298
5 ! and follow up to PR fortran/34319.
6 !
7 ! Check handling of "NAN(alphanum)"
8 !
9 character(len=200) :: str
10 real :: r
11 complex :: z
12
13 ! read_real:
14
15 r = 1.0
16 str = 'INfinity' ; read(str,*) r
17 if (r < 0 .or. r /= r*1.1) STOP 1
18
19 r = 1.0
20 str = '-INF' ; read(str,*) r
21 if (r > 0 .or. r /= r*1.1) STOP 2
22
23 r = 1.0
24 str = '+INF' ; read(str,*) r
25 if (r < 0 .or. r /= r*1.1) STOP 3
26
27 r = 1.0
28 str = '-inFiniTY' ; read(str,*) r
29 if (r > 0 .or. r /= r*1.1) STOP 4
30
31 r = 1.0
32 str = 'NAN' ; read(str,*) r
33 if (.not. isnan(r)) STOP 5
34
35 r = 1.0
36 str = '-NAN' ; read(str,*) r
37 if (.not. isnan(r)) STOP 6
38
39 r = 1.0
40 str = '+NAN' ; read(str,*) r
41 if (.not. isnan(r)) STOP 7
42
43 r = 1.0
44 str = 'NAN(0x111)' ; read(str,*) r
45 if (.not. isnan(r)) STOP 8
46
47 r = 1.0
48 str = '-NAN(123)' ; read(str,*) r
49 if (.not. isnan(r)) STOP 9
50
51 r = 1.0
52 str = '+NAN(0xFFE)' ; read(str,*) r
53 if (.not. isnan(r)) STOP 10
54
55
56 ! parse_real
57
58 z = cmplx(-2.0,-4.0)
59 str = '(0.0,INfinity)' ; read(str,*) z
60 if (aimag(z) < 0 .or. aimag(z) /= aimag(z)*1.1) STOP 11
61
62 z = cmplx(-2.0,-4.0)
63 str = '(-INF,0.0)' ; read(str,*) z
64 if (real(z) > 0 .or. real(z) /= real(z)*1.1) STOP 12
65
66 z = cmplx(-2.0,-4.0)
67 str = '(0.0,+INF)' ; read(str,*) z
68 if (aimag(z) < 0 .or. aimag(z) /= aimag(z)*1.1) STOP 13
69
70 z = cmplx(-2.0,-4.0)
71 str = '(-inFiniTY,0.0)' ; read(str,*) z
72 if (real(z) > 0 .or. real(z) /= real(z)*1.1) STOP 14
73
74 z = cmplx(-2.0,-4.0)
75 str = '(NAN,0.0)' ; read(str,*) z
76 if (.not. isnan(real(z))) STOP 15
77
78 z = cmplx(-2.0,-4.0)
79 str = '(0.0,-NAN)' ; read(str,*) z
80 if (.not. isnan(aimag(z))) STOP 16
81
82 z = cmplx(-2.0,-4.0)
83 str = '(+NAN,0.0)' ; read(str,*) z
84 if (.not. isnan(real(z))) STOP 17
85
86 z = cmplx(-2.0,-4.0)
87 str = '(NAN(0x111),0.0)' ; read(str,*) z
88 if (.not. isnan(real(z))) STOP 18
89
90 z = cmplx(-2.0,-4.0)
91 str = '(0.0,-NaN(123))' ; read(str,*) z
92 if (.not. isnan(aimag(z))) STOP 19
93
94 z = cmplx(-2.0,-4.0)
95 str = '(+nan(0xFFE),0.0)' ; read(str,*) z
96 if (.not. isnan(real(z))) STOP 20
97
98 end