]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR fortran/55539 Fix regression in -fno-sign-zero.
authorJanne Blomqvist <jb@gcc.gnu.org>
Tue, 25 Dec 2012 22:11:16 +0000 (00:11 +0200)
committerJanne Blomqvist <jb@gcc.gnu.org>
Tue, 25 Dec 2012 22:11:16 +0000 (00:11 +0200)
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.

From-SVN: r194717

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/nosigned_zero_3.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/write_float.def

index 8a99e06a5448368d933cf6a9937b001683e2f0c5..59f344106c1146a72d9f506d4d8a918041ba3fe3 100644 (file)
@@ -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 (file)
index 0000000..3f0f710
--- /dev/null
@@ -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
index 566a24bd55bfd56caadd9079aa5412ddcb69d8da..debd88c8f4f66f4515e77c52f3ebcb7257e21a1e 100644 (file)
@@ -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
index 6521f3c06232a0b560728531cfdf1beeeee366cc..1e30dde29ce21fab614250361bf9953e843f3f61 100644 (file)
@@ -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