From 0af30954688a9dc1fccdc7579807cb1f46b6ebd6 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Wed, 16 Nov 2016 17:27:04 +0000 Subject: [PR libgfortran/78314] Fix ieee_support_halting ieee_support_halting only checked the availability of status flags, not trapping support. On some targets the later can only be checked at runtime: feenableexcept reports if enabling traps failed. So check trapping support by enabling/disabling it. Updated the test that enabled trapping to check if it is supported. gcc/testsuite/ PR libgfortran/78314 * gfortran.dg/ieee/ieee_6.f90: Use ieee_support_halting. libgfortran/ PR libgfortran/78314 * config/fpu-glibc.h (support_fpu_trap): Use feenableexcept. From-SVN: r242505 --- libgfortran/config/fpu-glibc.h | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'libgfortran/config') diff --git a/libgfortran/config/fpu-glibc.h b/libgfortran/config/fpu-glibc.h index 6e505da..8b29a76 100644 --- a/libgfortran/config/fpu-glibc.h +++ b/libgfortran/config/fpu-glibc.h @@ -121,7 +121,41 @@ get_fpu_trap_exceptions (void) int support_fpu_trap (int flag) { - return support_fpu_flag (flag); + int exceptions = 0; + int old; + + if (!support_fpu_flag (flag)) + return 0; + +#ifdef FE_INVALID + if (flag & GFC_FPE_INVALID) exceptions |= FE_INVALID; +#endif + +#ifdef FE_DIVBYZERO + if (flag & GFC_FPE_ZERO) exceptions |= FE_DIVBYZERO; +#endif + +#ifdef FE_OVERFLOW + if (flag & GFC_FPE_OVERFLOW) exceptions |= FE_OVERFLOW; +#endif + +#ifdef FE_UNDERFLOW + if (flag & GFC_FPE_UNDERFLOW) exceptions |= FE_UNDERFLOW; +#endif + +#ifdef FE_DENORMAL + if (flag & GFC_FPE_DENORMAL) exceptions |= FE_DENORMAL; +#endif + +#ifdef FE_INEXACT + if (flag & GFC_FPE_INEXACT) exceptions |= FE_INEXACT; +#endif + + old = feenableexcept (exceptions); + if (old == -1) + return 0; + fedisableexcept (exceptions & ~old); + return 1; } -- cgit v1.1