From: Jerry DeLisle Date: Mon, 14 Jan 2019 01:12:27 +0000 (+0000) Subject: re PR libfortran/88776 (Namelist read from stdin: loss of data) X-Git-Tag: releases/gcc-7.5.0~660 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c24d270be376cc8db3130743de29480b0503ee7;p=thirdparty%2Fgcc.git re PR libfortran/88776 (Namelist read from stdin: loss of data) 2019-01-13 Jerry DeLisle PR libfortran/88776 * io/list_read.c (namelist_read): Use nml_err_ret path on read error not based on stdin_unit. * io/open.c (newunit): Free format buffer if the unit specified is for stdin, stdout, or stderr. * gfortran.dg/namelist_96.f90: New test. From-SVN: r267911 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 80317b36aa34..814a1e9d88ef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-13 Jerry DeLisle + + PR libfortran/88776 + * gfortran.dg/namelist_96.f90: New test. + 2019-01-11 Steven G. Kargl PR fortran/35031 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 0aec54a54488..b8b75e155f14 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,11 @@ +2019-01-13 Jerry DeLisle + + PR libfortran/88776 + * io/list_read.c (namelist_read): Use nml_err_ret path on read error + not based on stdin_unit. + * io/open.c (newunit): Free format buffer if the unit specified is for + stdin, stdout, or stderr. + 2018-12-06 Janne Blomqvist Backport from trunk diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index f907818f3795..dd8a9ffa573d 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -3613,11 +3613,7 @@ find_nml_name: while (!dtp->u.p.input_complete) { if (!nml_get_obj_data (dtp, &prev_nl, nml_err_msg, sizeof nml_err_msg)) - { - if (dtp->u.p.current_unit->unit_number != options.stdin_unit) - goto nml_err_ret; - generate_error (&dtp->common, LIBERROR_READ_VALUE, nml_err_msg); - } + goto nml_err_ret; /* Reset the previous namelist pointer if we know we are not going to be doing multiple reads within a single namelist object. */ diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index 9d3988a7c218..158ae69548d7 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -529,6 +529,14 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags *flags) if (u2 != NULL) unlock_unit (u2); + /* If the unit specified is preconnected with a file specified to be open, + then clear the format buffer. */ + if ((opp->common.unit == options.stdin_unit || + opp->common.unit == options.stdout_unit || + opp->common.unit == options.stderr_unit) + && (opp->common.flags & IOPARM_OPEN_HAS_FILE) != 0) + fbuf_destroy (u); + /* Open file. */ s = open_external (opp, flags);