diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2019-11-07 03:06:20 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2019-11-07 03:06:20 +0000 |
commit | 67732fbced89c42dabea4a3bc160da80d0db046a (patch) | |
tree | feabf2ec8e1c3d38e1b267137d531abd42748a24 /libgfortran/io/write.c | |
parent | ce6c0a20b5875c18a8416d60950febea76a4b9d3 (diff) | |
download | gcc-67732fbced89c42dabea4a3bc160da80d0db046a.zip gcc-67732fbced89c42dabea4a3bc160da80d0db046a.tar.gz gcc-67732fbced89c42dabea4a3bc160da80d0db046a.tar.bz2 |
re PR libfortran/90374 (Fortran 2018: Support d0.d, e0.d, es0.d, en0.d, g0.d and ew.d e0 edit descriptors for output)
2019-11-06 Jerry DeLisle <jvdelisle@gcc.ngu.org>
PR fortran/90374
* io.c (check_format): Allow zero width for D, E, EN, and ES
specifiers as default and when -std=F2018 is given. Retain
existing errors when using the -fdec family of flags.
* libgfortran/io/format.c (parse_format_list): Relax format checking for
zero width as default and when -std=f2018.
io/format.h (format_token): Move definition to io.h.
io/io.h (format_token): Add definition here to allow access to
this definition at higher levels. Rename the declaration of
write_real_g0 to write_real_w0 and add a new format_token
argument, allowing higher level functions to pass in the
token for handling of g0 vs the other zero width specifiers.
io/transfer.c (formatted_transfer_scalar_write): Add checks for
zero width and call write_real_w0 to handle it.
io/write.c (write_real_g0): Remove.
(write_real_w0): Add new, same as previous write_real_g0 except
check format token to handle the g0 case.
* gfortran.dg/fmt_error_10.f: Modify for new constraints.
* gfortran.dg/fmt_error_7.f: Add dg-options "-std=f95".
* gfortran.dg/fmt_error_9.f: Modify for new constraints.
* gfortran.dg/fmt_zero_width.f90: New test.
From-SVN: r277905
Diffstat (limited to 'libgfortran/io/write.c')
-rw-r--r-- | libgfortran/io/write.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index eacd1f7..5ebe83b 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -1720,25 +1720,32 @@ write_real (st_parameter_dt *dtp, const char *source, int kind) compensate for the extra digit. */ void -write_real_g0 (st_parameter_dt *dtp, const char *source, int kind, int d) +write_real_w0 (st_parameter_dt *dtp, const char *source, int kind, + format_token fmt, int d) { fnode f; char buf_stack[BUF_STACK_SZ]; char str_buf[BUF_STACK_SZ]; char *buffer, *result; size_t buf_size, res_len, flt_str_len; - int comp_d; + int comp_d = 0; set_fnode_default (dtp, &f, kind); if (d > 0) f.u.real.d = d; + f.format = fmt; + + /* For FMT_G, Compensate for extra digits when using scale factor, d + is not specified, and the magnitude is such that E editing + is used. */ + if (fmt == FMT_G) + { + if (dtp->u.p.scale_factor > 0 && d == 0) + comp_d = 1; + else + comp_d = 0; + } - /* Compensate for extra digits when using scale factor, d is not - specified, and the magnitude is such that E editing is used. */ - if (dtp->u.p.scale_factor > 0 && d == 0) - comp_d = 1; - else - comp_d = 0; dtp->u.p.g0_no_blanks = 1; /* Precision for snprintf call. */ @@ -1750,7 +1757,7 @@ write_real_g0 (st_parameter_dt *dtp, const char *source, int kind, int d) buffer = select_buffer (dtp, &f, precision, buf_stack, &buf_size, kind); get_float_string (dtp, &f, source , kind, comp_d, buffer, - precision, buf_size, result, &flt_str_len); + precision, buf_size, result, &flt_str_len); write_float_string (dtp, result, flt_str_len); dtp->u.p.g0_no_blanks = 0; |