diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5ca2aaf22af5a7135bcad857aacf7638c83b2a23..d750f25d328f848986eec79ce92cd17a3499d567 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-16 Szabolcs Nagy <szabolcs.nagy@arm.com> + + PR libgfortran/78314 + * gfortran.dg/ieee/ieee_6.f90: Use ieee_support_halting. + 2016-11-16 Bin Cheng <bin.cheng@arm.com> * gcc.target/arm/ivopts-orig_biv-inc.c: Adjust test string diff --git a/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90 b/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90 index 8fb4f6f80d20af1d2178cd4ee7a8947a935766c1..43aa3bfe0a51f292797bfcb0dcc01f707171c16b 100644 --- a/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90 +++ b/gcc/testsuite/gfortran.dg/ieee/ieee_6.f90 @@ -9,7 +9,7 @@ implicit none type(ieee_status_type) :: s1, s2 - logical :: flags(5), halt(5) + logical :: flags(5), halt(5), haltworks type(ieee_round_type) :: mode real :: x @@ -18,6 +18,7 @@ call ieee_set_flag(ieee_all, .false.) call ieee_set_rounding_mode(ieee_down) call ieee_set_halting_mode(ieee_all, .false.) + haltworks = ieee_support_halting(ieee_overflow) call ieee_get_status(s1) call ieee_set_status(s1) @@ -46,7 +47,7 @@ call ieee_get_rounding_mode(mode) if (mode /= ieee_to_zero) call abort call ieee_get_halting_mode(ieee_all, halt) - if ((.not. halt(1)) .or. any(halt(2:))) call abort + if ((haltworks .and. .not. halt(1)) .or. any(halt(2:))) call abort call ieee_set_status(s2) @@ -58,7 +59,7 @@ call ieee_get_rounding_mode(mode) if (mode /= ieee_to_zero) call abort call ieee_get_halting_mode(ieee_all, halt) - if ((.not. halt(1)) .or. any(halt(2:))) call abort + if ((haltworks .and. .not. halt(1)) .or. any(halt(2:))) call abort call ieee_set_status(s1) @@ -79,6 +80,6 @@ call ieee_get_rounding_mode(mode) if (mode /= ieee_to_zero) call abort call ieee_get_halting_mode(ieee_all, halt) - if ((.not. halt(1)) .or. any(halt(2:))) call abort + if ((haltworks .and. .not. halt(1)) .or. any(halt(2:))) call abort end diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 50305af70a881d9667d74b0ed676c07206cfc5ef..15fe6634eeb91b376ebeecb2df7b8d4abc681505 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2016-11-16 Szabolcs Nagy <szabolcs.nagy@arm.com> + + PR libgfortran/78314 + * config/fpu-glibc.h (support_fpu_trap): Use feenableexcept. + 2016-11-15 Jerry DeLisle <jvdelisle@gcc.gnu.org> Thomas Koenig <tkoenig@gcc.gnu.org> diff --git a/libgfortran/config/fpu-glibc.h b/libgfortran/config/fpu-glibc.h index 6e505da4e1fcb90a0a8a8fd2d37514c5ca5f8817..8b29a7603e5055e309112020476d3760ed3c05aa 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; }