re PR fortran/57822 (I/O: "(g0)" wrongly prints "E+0000")
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 12 Feb 2015 03:52:45 +0000 (03:52 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 12 Feb 2015 03:52:45 +0000 (03:52 +0000)
2015-02-11  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR libgfortran/57822
* gfortran/fmt_g0_7.f08: Revise test.

From-SVN: r220637

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/fmt_g0_7.f08

index ee5be51b54a189ca2e7e571064bb70997d6438fc..8d5d3f3725d6df1e6d2110c7d01bf6c482b7eb84 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-11  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libgfortran/57822
+       * gfortran/fmt_g0_7.f08: Revise test.
+
 2015-02-11  Jeff Law  <law@redhat.com>
 
        PR target/63347
index a70ead10b5867bd8f6b633ed957f76bf23ff5e40..3709b758c6e4d744bf880ee60f3df494368fbbc7 100644 (file)
@@ -1,28 +1,31 @@
 ! { dg-do run }
+! { dg-options "-std=gnu" }
 ! PR58722
 program testit
+use ISO_FORTRAN_ENV
+  implicit none
+  integer, parameter :: j(size(real_kinds))=REAL_KINDS
   character(50) :: astring
-  
-  write(astring, '(g0)') 0.1_4
-  if (test(astring)) call abort
-  write(astring, '(g0)') 0.1_8
-  if (test(astring)) call abort
-  write(astring, '(g0)') 0.1_10
-  if (test(astring)) call abort
-  write(astring, '(g0)') 0.1_16
-  if (test(astring)) call abort
+  integer :: i, l, n
 
-contains
-
-function test (string1) result(res)
-  character(len=*) :: string1
-  logical :: res
-
-  res = .true.
-  do i = 1, len(string1)
-    if (string1(i:i) == 'E') return
+  n = 0
+  do i=1,size(real_kinds)
+    if (i == 1) then
+      write(astring, '(ru,g0)') 1.0/real(10.0, kind=j(1))
+    else if (i == 2) then
+      write(astring, '(ru,g0)') 1.0/real(10.0, kind=j(2))
+    else if (i == 3) then
+      write(astring, '(ru,g0)') 1.0/real(10.0, kind=j(3))
+    else if (i == 4) then
+      write(astring, '(ru,g0)') 1.0/real(10.0, kind=j(4))
+    end if
+    if (astring(2:2) /= '9') then
+      l = index(astring, 'E')
+      if (l /= 0) then
+       !print *, i, l, trim(astring)
+       n = n + l
+      end if
+    end if
   end do
-  res = .false.
-end function
-
+  if (n /= 0) call abort
 end program