diff options
author | Tobias Burnus <burnus@net-b.de> | 2009-07-08 21:34:49 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2009-07-08 21:34:49 +0200 |
commit | 60d340efa77c1ae01cf3e7a66bcf402ca7793d7f (patch) | |
tree | 0a5ea8221f10c4245ae6b6625bf67d42c5a11bf1 /gcc/fortran/simplify.c | |
parent | 0f158db0bf587d51a8527e7399d258b5391bdfef (diff) | |
download | gcc-60d340efa77c1ae01cf3e7a66bcf402ca7793d7f.zip gcc-60d340efa77c1ae01cf3e7a66bcf402ca7793d7f.tar.gz gcc-60d340efa77c1ae01cf3e7a66bcf402ca7793d7f.tar.bz2 |
re PR fortran/40675 (Support -fnosign-zero for SIGN intrinsic for Fortran 77 compatibility)
2009-07-08 Tobias Burnus <burnus@net-b.de>
PR fortran/40675
* simplify.c (gfc_simplify_sign): Handle signed zero correctly.
* trans-intrinsic.c (gfc_conv_intrinsic_sign): Support
-fno-sign-zero.
* invoke.texi (-fno-sign-zero): Add text regarding SIGN
* intrinsic.
2009-07-08 Tobias Burnus <burnus@net-b.de>
PR fortran/40675
* gfortran.dg/nosigned_zero_1.f90: New test.
* gfortran.dg/nosigned_zero_2.f90: New test.
From-SVN: r149390
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r-- | gcc/fortran/simplify.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index f57f68e..c619f14 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -4957,16 +4957,15 @@ gfc_simplify_sign (gfc_expr *x, gfc_expr *y) mpz_abs (result->value.integer, x->value.integer); if (mpz_sgn (y->value.integer) < 0) mpz_neg (result->value.integer, result->value.integer); - break; case BT_REAL: - /* TODO: Handle -0.0 and +0.0 correctly on machines that support - it. */ - mpfr_abs (result->value.real, x->value.real, GFC_RND_MODE); - if (mpfr_sgn (y->value.real) < 0) - mpfr_neg (result->value.real, result->value.real, GFC_RND_MODE); - + if (gfc_option.flag_sign_zero) + mpfr_copysign (result->value.real, x->value.real, y->value.real, + GFC_RND_MODE); + else + mpfr_setsign (result->value.real, x->value.real, + mpfr_sgn (y->value.real) < 0 ? 1 : 0, GFC_RND_MODE); break; default: |