From e8e5329d0c32d897927b87db8cba2af9082d103f Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Tue, 11 Oct 2016 18:31:50 +0000 Subject: [PATCH] simplify.c (radians_f): Fix mpdr_mod. 2016-10-11 Jerry DeLisle * simplify.c (radians_f): Fix mpdr_mod. * ireolce.c (get_degrees): Declare tmp. From-SVN: r241000 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/iresolve.c | 1 + gcc/fortran/simplify.c | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 907a8ef41e9..025bfabb4aa 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-10-11 Jerry DeLisle + + * simplify.c (radians_f): Fix mpdr_mod. + * ireolce.c (get_degrees): Declare tmp. + 2016-10-11 Fritz Reese * lang.opt: New flag -fdec-math. diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c index f4f81b2e589..4334522c5e6 100644 --- a/gcc/fortran/iresolve.c +++ b/gcc/fortran/iresolve.c @@ -2702,6 +2702,7 @@ get_degrees (gfc_expr *rad) { gfc_expr *result, *factor; gfc_actual_arglist *mod_args; + mpfr_t tmp; gcc_assert (rad->ts.type == BT_REAL); diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index bf60f7475d6..18135d2f4a2 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -1768,11 +1768,13 @@ degrees_f (mpfr_t x, mp_rnd_t rnd_mode) static void radians_f (mpfr_t x, mp_rnd_t rnd_mode) { - mpfr_t tmp; + mpfr_t tmp, modtmp; mpfr_init (tmp); + mpfr_init (modtmp); /* Set x = x % 360 to avoid offsets with large angles. */ - mpfr_fmod_d (tmp, x, 360.0, rnd_mode); + mpfr_set_d (modtmp, 360.0, GFC_RND_MODE); + mpfr_fmod (tmp, x, modtmp, rnd_mode); /* Set x = x * pi. */ mpfr_const_pi (tmp, rnd_mode); @@ -1782,6 +1784,7 @@ radians_f (mpfr_t x, mp_rnd_t rnd_mode) mpfr_div_d (x, x, 180.0, rnd_mode); mpfr_clear (tmp); + mpfr_clear (modtmp); } -- 2.30.2