summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2012-12-25 22:11:16 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2012-12-25 22:11:16 +0000
commit49bbaf357ce357b961ee699141ae197302ca42ff (patch)
treed25ef69d03aac5fc041242a79c04c1cde4b3a5d1
parent5da54e196d3e1680f2c2be8ff3041dbc1575e858 (diff)
downloadgcc-49bbaf357ce357b961ee699141ae197302ca42ff.tar.gz
PR fortran/55539 Fix regression in -fno-sign-zero.
libgfortran ChangeLog: 2012-12-26 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/55539 * io/write_float.def (output_float): Take into account decimal dot. testsuite ChangeLog: 2012-12-26 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/55539 * gfortran.dg/nosigned_zero_3.f90: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194717 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/nosigned_zero_3.f9015
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/write_float.def9
4 files changed, 32 insertions, 3 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8a99e06a544..59f344106c1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-26 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/55539
+ * gfortran.dg/nosigned_zero_3.f90: New testcase.
+
2012-12-23 Tobias Burnus <burnus@net-b.de>
PR fortran/54884
diff --git a/gcc/testsuite/gfortran.dg/nosigned_zero_3.f90 b/gcc/testsuite/gfortran.dg/nosigned_zero_3.f90
new file mode 100644
index 00000000000..3f0f7101f26
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/nosigned_zero_3.f90
@@ -0,0 +1,15 @@
+! { dg-do run }
+! { dg-options "-fno-sign-zero" }
+!
+! PR fortran/55539
+!
+program nosigned_zero_3
+ implicit none
+ character(len=20) :: s
+ real(4) :: x = -1.2e-3
+ real(8) :: y = -1.2e-3
+ write(s,'(7f10.3)') x
+ if (trim(adjustl(s)) /= "-0.001") call abort
+ write(s, '(7f10.3)') y
+ if (trim(adjustl(s)) /= "-0.001") call abort
+end program nosigned_zero_3
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 566a24bd55b..debd88c8f4f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2012-12-26 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR fortran/55539
+ * io/write_float.def (output_float): Take into account decimal
+ dot.
+
2012-12-21 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/30162
diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def
index 6521f3c0623..1e30dde29ce 100644
--- a/libgfortran/io/write_float.def
+++ b/libgfortran/io/write_float.def
@@ -483,16 +483,19 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size,
/* Scan the digits string and count the number of zeros. If we make it
all the way through the loop, we know the value is zero after the
rounding completed above. */
- for (i = 0; i < ndigits; i++)
+ int hasdot = 0;
+ for (i = 0; i < ndigits + hasdot; i++)
{
- if (digits[i] != '0' && digits[i] != '.')
+ if (digits[i] == '.')
+ hasdot = 1;
+ else if (digits[i] != '0')
break;
}
/* To format properly, we need to know if the rounded result is zero and if
so, we set the zero_flag which may have been already set for
actual zero. */
- if (i == ndigits)
+ if (i == ndigits + hasdot)
{
zero_flag = true;
/* The output is zero, so set the sign according to the sign bit unless