This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix PR 34594 - error vs. EOF
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 26 Dec 2007 22:10:12 +0100
- Subject: Fix PR 34594 - error vs. EOF
Hello world,
this is a fix for PR 34594. Test case is adapted from Tobias B's bug
report. Regression-tested on i686-pc-linux-gnu.
OK for trunk?
Thomas
2007-12-26 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/34594
* runtime/error.c: If there was a previous error, don't
mask it with another error mesage, EOF or EOR condition.
2007-12-26 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/34594
* gfortran.dg/direct_io_8.f90: New test case.
Index: runtime/error.c
===================================================================
--- runtime/error.c (revision 131146)
+++ runtime/error.c (working copy)
@@ -410,6 +410,13 @@ translate_error (int code)
void
generate_error (st_parameter_common *cmp, int family, const char *message)
{
+
+ /* If there was a previous error, don't mask it with another
+ error message, EOF or EOR condition. */
+
+ if ((cmp->flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_ERROR)
+ return;
+
/* Set the error status. */
if ((cmp->flags & IOPARM_HAS_IOSTAT))
*cmp->iostat = (family == LIBERROR_OS) ? errno : family;
! { dg-do run }
! PR 34594 - this used to give runtime errors due to an
! end condition.
program main
implicit none
integer :: iou, i, ir, TEMP_CHANGES
i=44
ir = -42
open(11,file="foo.dat")
! Try a direct access read on a formatted sequential rile
READ (11, REC = I, ERR = 99) TEMP_CHANGES
call abort
99 continue
! Variant 2: ir is ok, but does not jump to 99
READ (11, REC = I, IOSTAT = IR, ERR = 98) TEMP_CHANGES
call abort
98 continue
if(ir == 0) then
call abort
end if
close(11,status="delete")
end program main