https://gcc.gnu.org/g:f9b36634b051e944444df8fa5a827f2bbcda0199
commit r16-5174-gf9b36634b051e944444df8fa5a827f2bbcda0199 Author: Jerry DeLisle <[email protected]> Date: Tue Nov 11 09:25:06 2025 -0800 Fortran: Final cleanup of zero width formats [PR90374] PR libfortran/90374 libgfortran/ChangeLog: PR libfortran/90374 * io/format.c (parse_format_list): Set exponent width to unspecified. gcc/testsuite/ChangeLog: PR libfortran/90374 * gfortran.dg/fmt_error_10.f: Update test case to pass. * gfortran.dg/fmt_zero_width.f90: Likewise. * gfortran.dg/pr111022.f90: Likewise. * gfortran.dg/pr96436_4.f90: Likewise. * gfortran.dg/pr96436_5.f90: Likewise. Diff: --- gcc/testsuite/gfortran.dg/fmt_error_10.f | 5 +++-- gcc/testsuite/gfortran.dg/fmt_zero_width.f90 | 20 ++++++++++---------- gcc/testsuite/gfortran.dg/pr111022.f90 | 6 +++--- gcc/testsuite/gfortran.dg/pr96436_4.f90 | 10 +++++----- gcc/testsuite/gfortran.dg/pr96436_5.f90 | 10 +++++----- libgfortran/io/format.c | 1 + 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/fmt_error_10.f b/gcc/testsuite/gfortran.dg/fmt_error_10.f index fc6620a60a6a..9ae2f324b2cf 100644 --- a/gcc/testsuite/gfortran.dg/fmt_error_10.f +++ b/gcc/testsuite/gfortran.dg/fmt_error_10.f @@ -14,12 +14,13 @@ write (line,'(1pd24.15e6)',iostat=istat, iomsg=msg) 1.0d0, 1.234 ! { dg-warning "Period required" } if (istat.ne.0) STOP 3 - if (line.ne." 1.000000000000000D+001.E+00") STOP 4 + if (line.ne." 1.000000000000000D+001.E+00") STOP 2 str = '(1pd0.15)' write (line,str,iostat=istat, iomsg=msg) 1.0d0 - if (line.ne."1.000000000000000D+0") STOP 5 + if (line.ne."1.000000000000000D+000") STOP 4 read (*,str,iostat=istat, iomsg=msg) x + if (istat.ne.5006 .or. msg(1:10).ne."Zero width") STOP 6 if (x.ne.555.25) STOP 7 diff --git a/gcc/testsuite/gfortran.dg/fmt_zero_width.f90 b/gcc/testsuite/gfortran.dg/fmt_zero_width.f90 index db2cca6e28ab..3ba897c7a12c 100644 --- a/gcc/testsuite/gfortran.dg/fmt_zero_width.f90 +++ b/gcc/testsuite/gfortran.dg/fmt_zero_width.f90 @@ -9,32 +9,32 @@ program pr90374 rn = 0.00314_4 afmt = "(D0.3)" write (aresult,fmt=afmt) rn - if (aresult /= "0.314D-2") stop 12 + if (aresult /= "0.314D-02") stop 12 afmt = "(E0.10)" write (aresult,fmt=afmt) rn - if (aresult /= "0.3139999928E-2") stop 15 + if (aresult /= "0.3139999928E-02") stop 15 afmt = "(ES0.10)" write (aresult,fmt=afmt) rn - if (aresult /= "3.1399999280E-3") stop 18 + if (aresult /= "3.1399999280E-03") stop 18 afmt = "(EN0.10)" write (aresult,fmt=afmt) rn - if (aresult /= "3.1399999280E-3") stop 21 + if (aresult /= "3.1399999280E-03") stop 21 afmt = "(G0.10)" write (aresult,fmt=afmt) rn - if (aresult /= "0.3139999928E-2") stop 24 + if (aresult /= "0.3139999928E-02") stop 24 afmt = "(E0.10e0)" write (aresult,fmt=afmt) rn if (aresult /= "0.3139999928E-2") stop 27 write (aresult,fmt="(D0.3)") rn - if (aresult /= "0.314D-2") stop 29 + if (aresult /= "0.314D-02") stop 29 write (aresult,fmt="(E0.10)") rn - if (aresult /= "0.3139999928E-2") stop 31 + if (aresult /= "0.3139999928E-02") stop 31 write (aresult,fmt="(ES0.10)") rn - if (aresult /= "3.1399999280E-3") stop 33 + if (aresult /= "3.1399999280E-03") stop 33 write (aresult,fmt="(EN0.10)") rn - if (aresult /= "3.1399999280E-3") stop 35 + if (aresult /= "3.1399999280E-03") stop 35 write (aresult,fmt="(G0.10)") rn - if (aresult /= "0.3139999928E-2") stop 37 + if (aresult /= "0.3139999928E-02") stop 37 write (aresult,fmt="(E0.10e0)") rn if (aresult /= "0.3139999928E-2") stop 39 write (aresult,fmt="(E0.10e3)") rn diff --git a/gcc/testsuite/gfortran.dg/pr111022.f90 b/gcc/testsuite/gfortran.dg/pr111022.f90 index eef55ff5ce08..798ba13fb30f 100644 --- a/gcc/testsuite/gfortran.dg/pr111022.f90 +++ b/gcc/testsuite/gfortran.dg/pr111022.f90 @@ -60,13 +60,13 @@ program pr111022 write(buffer,"(E0.3E0)") .6660_4 if (buffer.ne."0.666E+0") stop 27 write(buffer,"(E0.3)") .6660_4 - if (buffer.ne."0.666E+0") stop 28 + if (buffer.ne."0.666E+00") stop 28 write(buffer,"(E0.1E0)") .6660_4 if (buffer.ne."0.7E+0") stop 29 write(buffer,"(E0.1)") .6660_4 - if (buffer.ne."0.7E+0") stop 30 + if (buffer.ne."0.7E+00") stop 30 write(buffer,"(E0.5E0)") .6660_4 if (buffer.ne."0.66600E+0") stop 31 write(buffer,"(E0.5)") .6660_4 - if (buffer.ne."0.66600E+0") stop 32 + if (buffer.ne."0.66600E+00") stop 32 end program pr111022 diff --git a/gcc/testsuite/gfortran.dg/pr96436_4.f90 b/gcc/testsuite/gfortran.dg/pr96436_4.f90 index 7d2cfef0ef87..145c6cb3ac18 100644 --- a/gcc/testsuite/gfortran.dg/pr96436_4.f90 +++ b/gcc/testsuite/gfortran.dg/pr96436_4.f90 @@ -2,7 +2,7 @@ ! { dg-options "-std=f2018 -pedantic" } character(20) :: fmt -character(9) :: buffer +character(12) :: buffer fmt = "(1a1,f0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" if (buffer.ne.">3.00<") stop 1 @@ -11,15 +11,15 @@ write(buffer,fmt) ">", 0.3, "<" if (buffer.ne.">0.30<") stop 2 fmt = "(1a1,d0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" -if (buffer.ne.">0.30D+1<") stop 3 +if (buffer.ne.">0.30D+01<") stop 3 fmt = "(1a1,e0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" -if (buffer.ne.">0.30E+1<") stop 4 +if (buffer.ne.">0.30E+01<") stop 4 fmt = "(1a1,en0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" -if (buffer.ne.">3.00E+0<") stop 5 +if (buffer.ne.">3.00E+00<") stop 5 fmt = "(1a1,es0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" -if (buffer.ne.">3.00E+0<") stop 6 +if (buffer.ne.">3.00E+00<") stop 6 end diff --git a/gcc/testsuite/gfortran.dg/pr96436_5.f90 b/gcc/testsuite/gfortran.dg/pr96436_5.f90 index 3870d988f97c..4d95ed2fc26a 100644 --- a/gcc/testsuite/gfortran.dg/pr96436_5.f90 +++ b/gcc/testsuite/gfortran.dg/pr96436_5.f90 @@ -2,7 +2,7 @@ ! { dg-options "-pedantic" } character(20) :: fmt -character(9) :: buffer +character(12) :: buffer fmt = "(1a1,f0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" if (buffer.ne.">3.00<") stop 1 @@ -11,15 +11,15 @@ write(buffer,fmt) ">", 0.30, "<" if (buffer.ne.">0.30<") stop 2 fmt = "(1a1,d0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" -if (buffer.ne.">0.30D+1<") stop 3 +if (buffer.ne.">0.30D+01<") stop 3 fmt = "(1a1,e0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" -if (buffer.ne.">0.30E+1<") stop 4 +if (buffer.ne.">0.30E+01<") stop 4 fmt = "(1a1,en0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" -if (buffer.ne.">3.00E+0<") stop 5 +if (buffer.ne.">3.00E+00<") stop 5 fmt = "(1a1,es0.2,1a1)" write(buffer,fmt) ">", 3.0, "<" -if (buffer.ne.">3.00E+0<") stop 6 +if (buffer.ne.">3.00E+00<") stop 6 end diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index 87e21a9a4327..b125b47233e6 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -945,6 +945,7 @@ parse_format_list (st_parameter_dt *dtp, bool *seen_dd) goto finished; } tail->u.real.w = 0; + tail->u.real.e = -1; /* Look for the dot seperator. */ u = format_lex (fmt);
