public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Peter Bergner <bergner@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ibm/heads/gcc-9)] Fix EOF handling for arrays. Date: Tue, 04 Feb 2020 21:00:00 -0000 [thread overview] Message-ID: <20200204210034.83834.qmail@sourceware.org> (raw) https://gcc.gnu.org/g:f61f7b69491548dd438b3dcc895a3a528f560bfd commit f61f7b69491548dd438b3dcc895a3a528f560bfd Author: Thomas Koenig <tkoenig@gcc.gnu.org> Date: Mon Nov 25 20:04:28 2019 +0000 Fix EOF handling for arrays. 2019-11-25 Thomas Koenig <tkoenig@gcc.gnu.org> Harald Anlauf <anlauf@gmx.de> Backport from trunk PR fortran/92569 * io/transfer.c (transfer_array_inner): If position is at AFTER_ENDFILE in current unit, return from data loop. 2019-11-25 Thomas Koenig <tkoenig@gcc.gnu.org> Harald Anlauf <anlauf@gmx.de> Backport from trunk PR fortran/92569 * gfortran.dg/eof_6.f90: New test. Co-Authored-By: Harald Anlauf <anlauf@gmx.de> From-SVN: r278702 Diff: --- gcc/testsuite/ChangeLog | 7 ++++ gcc/testsuite/gfortran.dg/eof_6.f90 | 23 +++++++++++++ libgfortran/ChangeLog | 8 +++++ libgfortran/io/transfer.c | 66 ++++++++++++++++++++++++++++--------- 4 files changed, 89 insertions(+), 15 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 40c60b9..c07ef85 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-11-25 Thomas Koenig <tkoenig@gcc.gnu.org> + Harald Anlauf <anlauf@gmx.de> + + Backport from trunk + PR fortran/92569 + * gfortran.dg/eof_6.f90: New test. + 2019-11-25 Tobias Burnus <tobias@codesourcery.com Backport from mainline diff --git a/gcc/testsuite/gfortran.dg/eof_6.f90 b/gcc/testsuite/gfortran.dg/eof_6.f90 new file mode 100644 index 0000000..1c15557 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eof_6.f90 @@ -0,0 +1,23 @@ +! { dg-do run } +! { dg-options "-ffrontend-optimize" } +! PR 92569 - the EOF condition was not recognized with +! -ffrontend-optimize. Originjal test case by Bill Lipa. +program main + implicit none + real(kind=8) :: tdat(1000,10) + real(kind=8) :: res (10, 3) + integer :: i, j, k, np + + open (unit=20, status="scratch") + res = reshape([(real(i),i=1,30)], shape(res)) + write (20,'(10G12.5)') res + rewind 20 + do j = 1,1000 + read (20,*,end=1)(tdat(j,k),k=1,10) + end do + +1 continue + np = j-1 + if (np /= 3) stop 1 + if (any(transpose(res) /= tdat(1:np,:))) stop 2 +end program main diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 6dc32e8..5bf3cc8 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,11 @@ +2019-11-25 Thomas Koenig <tkoenig@gcc.gnu.org> + Harald Anlauf <anlauf@gmx.de> + + Backport from trunk + PR fortran/92569 + * io/transfer.c (transfer_array_inner): If position is + at AFTER_ENDFILE in current unit, return from data loop. + 2019-11-13 Tobias Burnus <tobias@codesourcery.com> Backport from mainline diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index c43360f..8ed0391 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -2529,26 +2529,62 @@ transfer_array_inner (st_parameter_dt *dtp, gfc_array_char *desc, int kind, data = GFC_DESCRIPTOR_DATA (desc); - while (data) + /* When reading, we need to check endfile conditions so we do not miss + an END=label. Make this separate so we do not have an extra test + in a tight loop when it is not needed. */ + + if (dtp->u.p.current_unit && dtp->u.p.mode == READING) { - dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize); - data += stride0 * tsize; - count[0] += tsize; - n = 0; - while (count[n] == extent[n]) + while (data) { - count[n] = 0; - data -= stride[n] * extent[n]; - n++; - if (n == rank) + if (unlikely (dtp->u.p.current_unit->endfile == AFTER_ENDFILE)) + return; + + dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize); + data += stride0 * tsize; + count[0] += tsize; + n = 0; + while (count[n] == extent[n]) { - data = NULL; - break; + count[n] = 0; + data -= stride[n] * extent[n]; + n++; + if (n == rank) + { + data = NULL; + break; + } + else + { + count[n]++; + data += stride[n]; + } } - else + } + } + else + { + while (data) + { + dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize); + data += stride0 * tsize; + count[0] += tsize; + n = 0; + while (count[n] == extent[n]) { - count[n]++; - data += stride[n]; + count[n] = 0; + data -= stride[n] * extent[n]; + n++; + if (n == rank) + { + data = NULL; + break; + } + else + { + count[n]++; + data += stride[n]; + } } } }
reply other threads:[~2020-02-04 21:00 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200204210034.83834.qmail@sourceware.org \ --to=bergner@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).