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* } }
5!
6! Check that simplification functions and runtime library agree on ERF,
7! ERFC and ERFC_SCALED, for quadruple-precision.
8!
9! XFAILed for SPU targets because our library implementation of
10! the double-precision erf/erfc functions is not accurate enough.
11!
12! XFAILed for IA64 Linux because of a glibc bug:
13! http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59227
14
15program test
16  use, intrinsic :: iso_fortran_env
17  implicit none
18
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
22
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))
28
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.)
39
40  CHECK(-0.0)
41  CHECK(-0.9)
42  CHECK(-1.9)
43  CHECK(-19.)
44  CHECK(-190.)
45
46contains
47
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
53
54end program test
55