aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/ieee
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2022-01-02 11:36:23 +0100
committerFrancois-Xavier Coudert <fxcoudert@gmail.com>2022-01-10 12:28:46 +0100
commit492954263e39346287a5a2a32bcc5312466a0ee1 (patch)
tree839dd37ee7e5d1ef72ae09a908ddb9bf55035282 /libgfortran/ieee
parentbe59671c5624fe8bf21ddb0192e97ebdfa4db381 (diff)
downloadgcc-492954263e39346287a5a2a32bcc5312466a0ee1.zip
gcc-492954263e39346287a5a2a32bcc5312466a0ee1.tar.gz
gcc-492954263e39346287a5a2a32bcc5312466a0ee1.tar.bz2
Fortran: Allow IEEE_CLASS to identify signaling NaNs
We use the issignaling macro, present in some libc's (notably glibc), when it is available. Compile all IEEE-related files in the library (both C and Fortran sources) with -fsignaling-nans to ensure maximum compatibility. libgfortran/ChangeLog: PR fortran/82207 * Makefile.am: Pass -fsignaling-nans for IEEE files. * Makefile.in: Regenerate. * ieee/ieee_helper.c: Use issignaling macro to recognized signaling NaNs. gcc/testsuite/ChangeLog: PR fortran/82207 * gfortran.dg/ieee/signaling_1.f90: New test. * gfortran.dg/ieee/signaling_1_c.c: New file.
Diffstat (limited to 'libgfortran/ieee')
-rw-r--r--libgfortran/ieee/ieee_helper.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libgfortran/ieee/ieee_helper.c b/libgfortran/ieee/ieee_helper.c
index d70728c..7a103df 100644
--- a/libgfortran/ieee/ieee_helper.c
+++ b/libgfortran/ieee/ieee_helper.c
@@ -25,6 +25,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "libgfortran.h"
+
+/* Check support for issignaling macro.
+ TODO: In the future, provide fallback implementations for IEEE types,
+ because many libc's do not have issignaling yet. */
+#ifndef issignaling
+# define issignaling(X) 0
+#endif
+
+
/* Prototypes. */
extern int ieee_class_helper_4 (GFC_REAL_4 *);
@@ -86,8 +95,10 @@ enum {
\
if (res == IEEE_QUIET_NAN) \
{ \
- /* TODO: Handle signaling NaNs */ \
- return res; \
+ if (issignaling (*value)) \
+ return IEEE_SIGNALING_NAN; \
+ else \
+ return IEEE_QUIET_NAN; \
} \
\
return res; \