From 511395eec6bb850257fcd92839e05042095856bf Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Sat, 4 Apr 2009 19:04:53 +0000 Subject: [PATCH] re PR fortran/39528 (repeated entries are not read when using list-directed input) 2009-04-04 Jerry DeLisle PR libfortran/39528 * gfortran.dg/read_repeat.f90: New test. 2009-04-04 Jerry DeLisle PR libfortran/39528 Backport from trunk. * io/list_read.c (list_formatted_read_scalar): Move check for read completion to just after the check for a repeated value. From-SVN: r145548 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/read_repeat.f90 | 24 +++++++++++++++++++++++ libgfortran/ChangeLog | 7 +++++++ libgfortran/io/list_read.c | 6 +++--- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/read_repeat.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 890ac47d339c..4f93fa4eab01 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-04-04 Jerry DeLisle + + PR libfortran/39528 + * gfortran.dg/read_repeat.f90: New test. + 2009-04-04 Paul Thomas PR fortran/39519 diff --git a/gcc/testsuite/gfortran.dg/read_repeat.f90 b/gcc/testsuite/gfortran.dg/read_repeat.f90 new file mode 100644 index 000000000000..192ebe81ffbf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/read_repeat.f90 @@ -0,0 +1,24 @@ +! { dg-do run } +! PR39528 repeated entries not read when using list-directed input. +! Test case derived from reporters example. +program rread + implicit none + integer :: iarr(1:7), ia, ib, i + + iarr = 0 + + write(10,*) " 2*1 3*2 /" + write(10,*) " 12" + write(10,*) " 13" + rewind(10) + + read(10,*) (iarr(i), i=1,7) + read(10,*) ia, ib + + if (any(iarr(1:2).ne.1)) call abort + if (any(iarr(3:5).ne.2)) call abort + if (any(iarr(6:7).ne.0)) call abort + if (ia .ne. 12 .or. ib .ne. 13) call abort + + close(10, status="delete") +end program rread diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 452b168bd2e1..29b18925bbc5 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2009-04-04 Jerry DeLisle + + PR libfortran/39528 + Backport from trunk. + * io/list_read.c (list_formatted_read_scalar): Move check for read + completion to just after the check for a repeated value. + 2009-01-24 Release Manager * GCC 4.3.3 released. diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index 2375432fae97..367caeaf3946 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -1712,9 +1712,6 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p, int kind, } else { - if (dtp->u.p.input_complete) - goto cleanup; - if (dtp->u.p.repeat_count > 0) { if (check_type (dtp, type, kind)) @@ -1722,6 +1719,9 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p, int kind, goto set_value; } + if (dtp->u.p.input_complete) + goto cleanup; + if (dtp->u.p.at_eol) finish_separator (dtp); else -- 2.47.2