Debian Codegraph @

gcc/testsuite/gfortran.dg/ieee/intrinsics_1.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fno-range-check" }
3 !
4 ! Check compile-time simplification of functions FRACTION, EXPONENT,
5 ! SPACING, RRSPACING and SET_EXPONENT for special values.
6
7 program test
8 implicit none
9 real, parameter :: inf = 2 * huge(0.)
10 real, parameter :: nan = 0. / 0.
11
12 call check_positive_zero(fraction(0.))
13 call check_negative_zero(fraction(-0.))
14 if (.not. isnan(fraction(inf))) STOP 1
15 if (.not. isnan(fraction(-inf))) STOP 2
16 if (.not. isnan(fraction(nan))) STOP 3
17
18 if (exponent(0.) /= 0) STOP 4
19 if (exponent(-0.) /= 0) STOP 5
20 if (exponent(inf) /= huge(0)) STOP 6
21 if (exponent(-inf) /= huge(0)) STOP 7
22 if (exponent(nan) /= huge(0)) STOP 8
23
24 if (spacing(0.) /= spacing(tiny(0.))) STOP 9
25 if (spacing(-0.) /= spacing(tiny(0.))) STOP 10
26 if (.not. isnan(spacing(inf))) STOP 11
27 if (.not. isnan(spacing(-inf))) STOP 12
28 if (.not. isnan(spacing(nan))) STOP 13
29
30 call check_positive_zero(rrspacing(0.))
31 call check_positive_zero(rrspacing(-0.))
32 if (.not. isnan(rrspacing(inf))) STOP 14
33 if (.not. isnan(rrspacing(-inf))) STOP 15
34 if (.not. isnan(rrspacing(nan))) STOP 16
35
36 call check_positive_zero(set_exponent(0.,42))
37 call check_negative_zero(set_exponent(-0.,42))
38 if (.not. isnan(set_exponent(inf, 42))) STOP 17
39 if (.not. isnan(set_exponent(-inf, 42))) STOP 18
40 if (.not. isnan(set_exponent(nan, 42))) STOP 19
41
42 contains
43
44 subroutine check_positive_zero(x)
45 use ieee_arithmetic
46 implicit none
47 real, value :: x
48
49 if (ieee_class (x) /= ieee_positive_zero) STOP 20
50 end
51
52 subroutine check_negative_zero(x)
53 use ieee_arithmetic
54 implicit none
55 real, value :: x
56
57 if (ieee_class (x) /= ieee_negative_zero) STOP 21
58 end
59
60 end