2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / erf_3.F90
blobdf82e126bd8c6183adfba58adcec876f012b00fb
1 ! { dg-do run { xfail spu-*-* ia64-*-linux* } }
2 ! { dg-options "-fno-range-check -ffree-line-length-none -O0" }
3 ! { dg-add-options ieee }
4 ! { dg-skip-if "PR libfortran/59313" { hppa*-*-hpux* } }
6 ! Check that simplification functions and runtime library agree on ERF,
7 ! ERFC and ERFC_SCALED, for quadruple-precision.
9 ! XFAILed for SPU targets because our library implementation of
10 ! the double-precision erf/erfc functions is not accurate enough.
12 ! XFAILed for IA64 Linux because of a glibc bug:
13 ! http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59227
15 program test
16   use, intrinsic :: iso_fortran_env
17   implicit none
19   ! QP will be the largest supported real kind, possibly real(kind=16)
20   integer, parameter :: qp = real_kinds(ubound(real_kinds,dim=1))
21   real(kind=qp) :: x
23 #define CHECK(a) \
24   x = a ; \
25   call check(erf(real(a,kind=qp)), erf(x)) ; \
26   call check(erfc(real(a,kind=qp)), erfc(x)) ; \
27   call check(erfc_scaled(real(a,kind=qp)), erfc_scaled(x))
29   CHECK(0.0)
30   CHECK(0.9)
31   CHECK(1.9)
32   CHECK(10.)
33   CHECK(11.)
34   CHECK(12.)
35   CHECK(13.)
36   CHECK(14.)
37   CHECK(49.)
38   CHECK(190.)
40   CHECK(-0.0)
41   CHECK(-0.9)
42   CHECK(-1.9)
43   CHECK(-19.)
44   CHECK(-190.)
46 contains
48   subroutine check (a, b)
49     real(kind=qp), intent(in) :: a, b
50     print *, abs(a-b) / spacing(a)
51     if (abs(a - b) > 10 * spacing(a)) call abort
52   end subroutine
54 end program test