]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libfortran/88776 (Namelist read from stdin: loss of data)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Mon, 14 Jan 2019 01:12:27 +0000 (01:12 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Mon, 14 Jan 2019 01:12:27 +0000 (01:12 +0000)
2019-01-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

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

gcc/testsuite/ChangeLog
libgfortran/ChangeLog
libgfortran/io/list_read.c
libgfortran/io/open.c

index 80317b36aa348530af17099c0239a34bc9a6dfb3..814a1e9d88eff4442bf672f5144a0dc71c41c1d7 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libfortran/88776
+       * gfortran.dg/namelist_96.f90: New test.
+
 2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/35031
index 0aec54a54488dd1e15e4221a724488b6fcd1370f..b8b75e155f14f34e8cf80e6580340aae647377ab 100644 (file)
@@ -1,3 +1,11 @@
+2019-01-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       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  <jb@gcc.gnu.org>
 
        Backport from trunk
index f907818f379599b3336dac46c85f444935e12614..dd8a9ffa573dceebca06cc363be9997455149693 100644 (file)
@@ -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.  */
index 9d3988a7c2180b8f11e1306a0c12d46e73567fd9..158ae69548d7da0b62c33e2ac4826bf2fa311eb7 100644 (file)
@@ -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);