Message ID | bcfd86b4-c993-bd1c-8ba5-ff54abb4567c@charter.net |
---|---|
State | New |
Headers | show |
Series | [fortran] PR90374 add e0 zero width exponent support | expand |
On Thu, Nov 28, 2019 at 07:45:25AM -0800, Jerry DeLisle wrote: > + if (u == FMT_ZERO) > + { > + if (!gfc_notify_std (GFC_STD_F2018, > + "Positive exponent width required in " > + "format string at %L", &format_locus)) > + { > + saved_token = u; > + goto fail; > + } > + } > + else > + { > + error = G_("Positive exponent width required in format" > + "string at %L"); This needs a space after "format" or before "string". > + goto syntax; > + } > }
On 11/28/19 7:53 AM, Steve Kargl wrote: > On Thu, Nov 28, 2019 at 07:45:25AM -0800, Jerry DeLisle wrote: >> + if (u == FMT_ZERO) >> + { >> + if (!gfc_notify_std (GFC_STD_F2018, >> + "Positive exponent width required in " >> + "format string at %L", &format_locus)) >> + { >> + saved_token = u; >> + goto fail; >> + } >> + } >> + else >> + { >> + error = G_("Positive exponent width required in format" >> + "string at %L"); > > This needs a space after "format" or before "string". > >> + goto syntax; >> + } >> } > Fixed. OK with that? Jerry
On Thu, Nov 28, 2019 at 08:05:31AM -0800, Jerry DeLisle wrote: > On 11/28/19 7:53 AM, Steve Kargl wrote: > > On Thu, Nov 28, 2019 at 07:45:25AM -0800, Jerry DeLisle wrote: > >> + if (u == FMT_ZERO) > >> + { > >> + if (!gfc_notify_std (GFC_STD_F2018, > >> + "Positive exponent width required in " > >> + "format string at %L", &format_locus)) > >> + { > >> + saved_token = u; > >> + goto fail; > >> + } > >> + } > >> + else > >> + { > >> + error = G_("Positive exponent width required in format" > >> + "string at %L"); > > > > This needs a space after "format" or before "string". > > > >> + goto syntax; > >> + } > >> } > > > > Fixed. OK with that? > LGTM.
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 57a3fdd5152..70aa6474445 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1007,9 +1007,22 @@ data_desc: goto fail; if (u != FMT_POSINT) { - error = G_("Positive exponent width required in format string " - "at %L"); - goto syntax; + if (u == FMT_ZERO) + { + if (!gfc_notify_std (GFC_STD_F2018, + "Positive exponent width required in " + "format string at %L", &format_locus)) + { + saved_token = u; + goto fail; + } + } + else + { + error = G_("Positive exponent width required in format" + "string at %L"); + goto syntax; + } } } diff --git a/gcc/testsuite/gfortran.dg/fmt_zero_width.f90 b/gcc/testsuite/gfortran.dg/fmt_zero_width.f90 index 093c0a44c34..640b6735c65 100644 --- a/gcc/testsuite/gfortran.dg/fmt_zero_width.f90 +++ b/gcc/testsuite/gfortran.dg/fmt_zero_width.f90 @@ -1,11 +1,11 @@ ! { dg-do run } ! PR90374 "5.5 d0.d, e0.d, es0.d, en0.d, g0.d and ew.d edit descriptors program pr90374 + implicit none real(4) :: rn character(32) :: afmt, aresult - real(8) :: one = 1.0D0, zero = 0.0D0, nan, pinf, minf + real(8) :: one = 1.0D0, zero = 0.0D0, pinf, minf - nan = zero/zero rn = 0.00314_4 afmt = "(D0.3)" write (aresult,fmt=afmt) rn @@ -22,15 +22,19 @@ program pr90374 afmt = "(G0.10)" write (aresult,fmt=afmt) rn if (aresult /= "0.3139999928E-02") stop 24 + afmt = "(E0.10e0)" + write (aresult,fmt=afmt) rn + if (aresult /= "0.3139999928E-02") stop 27 write (aresult,fmt="(D0.3)") rn - if (aresult /= "0.314D-02") stop 26 + if (aresult /= "0.314D-02") stop 29 write (aresult,fmt="(E0.10)") rn - if (aresult /= "0.3139999928E-02") stop 28 + if (aresult /= "0.3139999928E-02") stop 31 write (aresult,fmt="(ES0.10)") rn - if (aresult /= "3.1399999280E-03") stop 30 + if (aresult /= "3.1399999280E-03") stop 33 write (aresult,fmt="(EN0.10)") rn - if (aresult /= "3.1399999280E-03") stop 32 + if (aresult /= "3.1399999280E-03") stop 35 write (aresult,fmt="(G0.10)") rn - if (aresult /= "0.3139999928E-02") stop 34 - + if (aresult /= "0.3139999928E-02") stop 37 + write (aresult,fmt="(E0.10e0)") rn + if (aresult /= "0.3139999928E-02") stop 39 end diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index b33620815d5..dd448c83e87 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -1027,11 +1027,17 @@ parse_format_list (st_parameter_dt *dtp, bool *seen_dd) { t = format_lex (fmt); if (t != FMT_POSINT) - { - fmt->error = "Positive exponent width required in format"; - goto finished; - } - + if (t == FMT_ZERO) + { + notify_std (&dtp->common, GFC_STD_F2018, + "Positive exponent width required"); + } + else + { + fmt->error = "Positive exponent width required in " + "format string at %L"; + goto finished; + } tail->u.real.e = fmt->value; } diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index daa16679f53..ce6aec83114 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -482,7 +482,7 @@ build_float_string (st_parameter_dt *dtp, const fnode *f, char *buffer, for (i = abs (e); i >= 10; i /= 10) edigits++; - if (f->u.real.e < 0) + if (f->u.real.e <= 0) { /* Width not specified. Must be no more than 3 digits. */ if (e > 999 || e < -999)