From faedeff79d9d6d9b0f8bc560ce7b53cf4e2598e7 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Thu, 12 Feb 2015 03:52:45 +0000 Subject: [PATCH] re PR fortran/57822 (I/O: "(g0)" wrongly prints "E+0000") 2015-02-11 Jerry DeLisle PR libgfortran/57822 * gfortran/fmt_g0_7.f08: Revise test. From-SVN: r220637 --- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gfortran.dg/fmt_g0_7.f08 | 45 ++++++++++++++------------ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ee5be51b54a..8d5d3f3725d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-11 Jerry DeLisle + + PR libgfortran/57822 + * gfortran/fmt_g0_7.f08: Revise test. + 2015-02-11 Jeff Law PR target/63347 diff --git a/gcc/testsuite/gfortran.dg/fmt_g0_7.f08 b/gcc/testsuite/gfortran.dg/fmt_g0_7.f08 index a70ead10b58..3709b758c6e 100644 --- a/gcc/testsuite/gfortran.dg/fmt_g0_7.f08 +++ b/gcc/testsuite/gfortran.dg/fmt_g0_7.f08 @@ -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 -- 2.30.2