mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
re PR libfortran/32611 (Print sign of negative zero)
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. Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> From-SVN: r126654
This commit is contained in:
parent
639d3040d4
commit
2bb6de3a7e
@ -1,3 +1,17 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2007-07-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
2007-07-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||||
|
|
||||||
PR libgfortran/32752
|
PR libgfortran/32752
|
||||||
|
@ -590,7 +590,7 @@ GFORTRAN_1.0 {
|
|||||||
_gfortran_set_fpe;
|
_gfortran_set_fpe;
|
||||||
_gfortran_set_max_subrecord_length;
|
_gfortran_set_max_subrecord_length;
|
||||||
_gfortran_set_record_marker;
|
_gfortran_set_record_marker;
|
||||||
_gfortran_set_std;
|
_gfortran_set_options;
|
||||||
_gfortran_shape_16;
|
_gfortran_shape_16;
|
||||||
_gfortran_shape_4;
|
_gfortran_shape_4;
|
||||||
_gfortran_shape_8;
|
_gfortran_shape_8;
|
||||||
|
@ -465,6 +465,7 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value)
|
|||||||
int leadzero;
|
int leadzero;
|
||||||
int nblanks;
|
int nblanks;
|
||||||
int i;
|
int i;
|
||||||
|
int sign_bit;
|
||||||
sign_t sign;
|
sign_t sign;
|
||||||
|
|
||||||
ft = f->format;
|
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
|
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. */
|
after the decimal point, plus another one before the decimal point. */
|
||||||
sign = calculate_sign (dtp, value < 0.0);
|
sign = calculate_sign (dtp, value < 0.0);
|
||||||
|
sign_bit = signbit (value);
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
value = -value;
|
value = -value;
|
||||||
|
|
||||||
@ -547,9 +549,15 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value)
|
|||||||
/* Read the exponent back in. */
|
/* Read the exponent back in. */
|
||||||
e = atoi (&buffer[ndigits + 3]) + 1;
|
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)
|
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. */
|
/* Normalize the fractional component. */
|
||||||
buffer[2] = buffer[1];
|
buffer[2] = buffer[1];
|
||||||
@ -751,7 +759,14 @@ output_float (st_parameter_dt *dtp, const fnode *f, GFC_REAL_LARGEST value)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == ndigits)
|
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. */
|
/* Work out how much padding is needed. */
|
||||||
nblanks = w - (nbefore + nzero + nafter + edigits + 1);
|
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. */
|
/* Pad to full field width. */
|
||||||
|
|
||||||
|
|
||||||
if ( ( nblanks > 0 ) && !dtp->u.p.no_leading_blank)
|
if ( ( nblanks > 0 ) && !dtp->u.p.no_leading_blank)
|
||||||
{
|
{
|
||||||
memset (out, ' ', nblanks);
|
memset (out, ' ', nblanks);
|
||||||
|
@ -382,6 +382,7 @@ typedef struct
|
|||||||
int convert;
|
int convert;
|
||||||
int dump_core;
|
int dump_core;
|
||||||
int backtrace;
|
int backtrace;
|
||||||
|
int sign_zero;
|
||||||
size_t record_marker;
|
size_t record_marker;
|
||||||
int max_subrecord_length;
|
int max_subrecord_length;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Handling of compile-time options that influence the library.
|
/* Handling of compile-time options that influence the library.
|
||||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
Copyright (C) 2005, 2007 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of the GNU Fortran 95 runtime library (libgfortran).
|
This file is part of the GNU Fortran 95 runtime library (libgfortran).
|
||||||
|
|
||||||
@ -35,23 +35,25 @@ Boston, MA 02110-1301, USA. */
|
|||||||
/* Useful compile-time options will be stored in here. */
|
/* Useful compile-time options will be stored in here. */
|
||||||
compile_options_t compile_options;
|
compile_options_t compile_options;
|
||||||
|
|
||||||
|
/* Set the usual compile-time options. */
|
||||||
/* Prototypes */
|
extern void set_options (int , int []);
|
||||||
extern void set_std (GFC_INTEGER_4, GFC_INTEGER_4, GFC_INTEGER_4,
|
export_proto(set_options);
|
||||||
GFC_INTEGER_4, GFC_INTEGER_4);
|
|
||||||
export_proto(set_std);
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
set_std (GFC_INTEGER_4 warn_std, GFC_INTEGER_4 allow_std,
|
set_options (int num, int options[])
|
||||||
GFC_INTEGER_4 pedantic, GFC_INTEGER_4 dump_core,
|
|
||||||
GFC_INTEGER_4 backtrace)
|
|
||||||
{
|
{
|
||||||
compile_options.pedantic = pedantic;
|
if (num >= 1)
|
||||||
compile_options.warn_std = warn_std;
|
compile_options.warn_std = options[0];
|
||||||
compile_options.allow_std = allow_std;
|
if (num >= 2)
|
||||||
compile_options.dump_core = dump_core;
|
compile_options.allow_std = options[1];
|
||||||
compile_options.backtrace = backtrace;
|
if (num >= 3)
|
||||||
|
compile_options.pedantic = options[2];
|
||||||
|
if (num >= 4)
|
||||||
|
compile_options.dump_core = options[3];
|
||||||
|
if (num >= 5)
|
||||||
|
compile_options.backtrace = options[4];
|
||||||
|
if (num >= 6)
|
||||||
|
compile_options.sign_zero = options[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +69,7 @@ init_compile_options (void)
|
|||||||
compile_options.pedantic = 0;
|
compile_options.pedantic = 0;
|
||||||
compile_options.dump_core = 0;
|
compile_options.dump_core = 0;
|
||||||
compile_options.backtrace = 0;
|
compile_options.backtrace = 0;
|
||||||
|
compile_options.sign_zero = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function called by the front-end to tell us the
|
/* Function called by the front-end to tell us the
|
||||||
|
Loading…
Reference in New Issue
Block a user