aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2022-01-17 12:46:48 +0100
committerFrancois-Xavier Coudert <fxcoudert@gmail.com>2022-01-24 23:16:16 +0100
commite89d0befe3ec3238fca6de2cb078eb403b8c7e99 (patch)
tree41fae2bcc0c07ac87ddfa6c3c32dc3a9b283fb47 /gcc
parent4343f5e256791a5abaaef29fe1f831a03bab129e (diff)
downloadgcc-e89d0befe3ec3238fca6de2cb078eb403b8c7e99.zip
gcc-e89d0befe3ec3238fca6de2cb078eb403b8c7e99.tar.gz
gcc-e89d0befe3ec3238fca6de2cb078eb403b8c7e99.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gfortran.dg/ieee/signaling_1.f901
-rw-r--r--gcc/testsuite/gfortran.dg/ieee/signaling_2.f902
-rw-r--r--gcc/testsuite/gfortran.dg/ieee/signaling_3.f9042
3 files changed, 44 insertions, 1 deletions
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