diff options
author | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-15 16:26:22 +0000 |
---|---|---|
committer | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-15 16:26:22 +0000 |
commit | d4862c77ebd88b4abbb75f8eda2d711107037e24 (patch) | |
tree | 5dd0bb4b6a1ee0a04fd08df75bf78b4ef75d74d7 /libgfortran/io | |
parent | 5a30047cc1166eb6ec0def314673f9535c5d44b7 (diff) | |
download | gcc-d4862c77ebd88b4abbb75f8eda2d711107037e24.tar.gz |
2007-07-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/32611
* runtime/compile_options.c (set_std): Remove.
(set_options): New function.
(init_compile_options): Add initialization for -fsign-zero option.
* gfortran.map (GFORTRAN_1.0): Rename _gfortran_set_std into
_gfortran_set_options.
* libgfortran.h (compile_options_t): Add sign_zero field.
* io/write.c (output_float): Use the sign bit of the value to determine
if a negative sign should be emitted for zero values. Do not emit the
negative sign for zero if -fno-sign-zero was set during compile.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126654 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/write.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 766d268993b..b4e5d3efb8f 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -465,6 +465,7 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value) int leadzero; int nblanks; int i; + int sign_bit; sign_t sign; ft = f->format; @@ -482,6 +483,7 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value) For an N digit exponent, this gives us (MIN_FIELD_WIDTH-5)-N digits after the decimal point, plus another one before the decimal point. */ sign = calculate_sign (dtp, value < 0.0); + sign_bit = signbit (value); if (value < 0) value = -value; @@ -547,9 +549,15 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value) /* Read the exponent back in. */ e = atoi (&buffer[ndigits + 3]) + 1; - /* Make sure zero comes out as 0.0e0. */ + /* Make sure zero comes out as 0.0e0. */ if (value == 0.0) - e = 0; + { + e = 0; + if (compile_options.sign_zero == 1) + sign = calculate_sign (dtp, sign_bit); + else + sign = calculate_sign (dtp, 0); + } /* Normalize the fractional component. */ buffer[2] = buffer[1]; @@ -751,7 +759,14 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value) break; } if (i == ndigits) - sign = calculate_sign (dtp, 0); + { + /* The output is zero, so set the sign according to the sign bit unless + -fno-sign-zero was specified. */ + if (compile_options.sign_zero == 1) + sign = calculate_sign (dtp, sign_bit); + else + sign = calculate_sign (dtp, 0); + } /* Work out how much padding is needed. */ nblanks = w - (nbefore + nzero + nafter + edigits + 1); @@ -776,7 +791,6 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value) /* Pad to full field width. */ - if ( ( nblanks > 0 ) && !dtp->u.p.no_leading_blank) { memset (out, ' ', nblanks); |