From e89d0befe3ec3238fca6de2cb078eb403b8c7e99 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Mon, 17 Jan 2022 12:46:48 +0100 Subject: Fortran: provide a fallback implementation of issignaling For targets with IEEE support but without the issignaling macro in libc (currently, everywhere except glibc), this allows us to provide a fallback implementation. In order to keep the code in ieee_helper.c relatively readable, I've put that new implementation in a separate file, issignaling_fallback.h. libgfortran/ChangeLog: * ieee/issignaling_fallback.h: New file. * ieee/ieee_helper.c: Include issignaling_fallback.h when target does not define issignaling macro. gcc/testsuite/ChangeLog: * gfortran.dg/ieee/signaling_1.f90: Do not require issignaling. * gfortran.dg/ieee/signaling_2.f90: Add comment. * gfortran.dg/ieee/signaling_3.f90: New test. --- gcc/testsuite/gfortran.dg/ieee/signaling_1.f90 | 1 - gcc/testsuite/gfortran.dg/ieee/signaling_2.f90 | 2 ++ gcc/testsuite/gfortran.dg/ieee/signaling_3.f90 | 42 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/ieee/signaling_3.f90 (limited to 'gcc') diff --git a/gcc/testsuite/gfortran.dg/ieee/signaling_1.f90 b/gcc/testsuite/gfortran.dg/ieee/signaling_1.f90 index 94ece3a..1c7c7cf 100644 --- a/gcc/testsuite/gfortran.dg/ieee/signaling_1.f90 +++ b/gcc/testsuite/gfortran.dg/ieee/signaling_1.f90 @@ -1,7 +1,6 @@ ! { dg-do run { xfail { { i?86-*-* x86_64-*-* } && ilp32 } } } ! x87 / x86-32 ABI is unsuitable for signaling NaNs ! -! { dg-require-effective-target issignaling } */ ! { dg-additional-sources signaling_1_c.c } ! { dg-additional-options "-w" } ! The -w option is needed to make cc1 not report a warning for diff --git a/gcc/testsuite/gfortran.dg/ieee/signaling_2.f90 b/gcc/testsuite/gfortran.dg/ieee/signaling_2.f90 index ff37ab6..ee38052 100644 --- a/gcc/testsuite/gfortran.dg/ieee/signaling_2.f90 +++ b/gcc/testsuite/gfortran.dg/ieee/signaling_2.f90 @@ -2,6 +2,8 @@ ! x87 / x86-32 ABI is unsuitable for signaling NaNs ! ! { dg-require-effective-target issignaling } */ +! The companion C source needs access to the issignaling macro. +! ! { dg-additional-sources signaling_2_c.c } ! { dg-additional-options "-w" } ! The -w option is needed to make cc1 not report a warning for diff --git a/gcc/testsuite/gfortran.dg/ieee/signaling_3.f90 b/gcc/testsuite/gfortran.dg/ieee/signaling_3.f90 new file mode 100644 index 0000000..45bd9c35 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ieee/signaling_3.f90 @@ -0,0 +1,42 @@ +! { dg-do run } +! +program test + use, intrinsic :: iso_c_binding + use, intrinsic :: ieee_arithmetic + implicit none + + real(kind=c_float) :: x + real(kind=c_double) :: y + real(kind=c_long_double) :: z + + if (ieee_support_nan(x)) then + x = ieee_value(x, ieee_signaling_nan) + if (ieee_class(x) /= ieee_signaling_nan) stop 100 + if (.not. ieee_is_nan(x)) stop 101 + + x = ieee_value(x, ieee_quiet_nan) + if (ieee_class(x) /= ieee_quiet_nan) stop 103 + if (.not. ieee_is_nan(x)) stop 104 + end if + + if (ieee_support_nan(y)) then + y = ieee_value(y, ieee_signaling_nan) + if (ieee_class(y) /= ieee_signaling_nan) stop 100 + if (.not. ieee_is_nan(y)) stop 101 + + y = ieee_value(y, ieee_quiet_nan) + if (ieee_class(y) /= ieee_quiet_nan) stop 103 + if (.not. ieee_is_nan(y)) stop 104 + end if + + if (ieee_support_nan(z)) then + z = ieee_value(z, ieee_signaling_nan) + if (ieee_class(z) /= ieee_signaling_nan) stop 100 + if (.not. ieee_is_nan(z)) stop 101 + + z = ieee_value(z, ieee_quiet_nan) + if (ieee_class(z) /= ieee_quiet_nan) stop 103 + if (.not. ieee_is_nan(z)) stop 104 + end if + +end program test -- cgit v1.1