This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, libgfortran] PR45532 gfortran namelist read error
- From: Jerry DeLisle <jvdelisle at frontier dot com>
- To: gfortran <fortran at gcc dot gnu dot org>
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 13 Sep 2010 21:21:54 -0700
- Subject: [patch, libgfortran] PR45532 gfortran namelist read error
Hi folks,
The attached patch is simple, but was hard to find until I just took a hack at
it and got different results. I was then able to compare failing test cases
with passing ones at that point and the obvious difference was whether or not
pprev_nl was set yet.
Regression tested on x86-64-linux-gnu.
I will commit shortly to trunk and backport to 4.4 and 4.5 following a few days.
Regards,
Jerry
2010-09-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/45532
* io/list_read.c (nml_get_obj_data): Set first_nl if the previous
is NULL.
Test case:
! { dg-do run }
! PR45532 gfortran namelist read error.
! Derived from the original test case by David Sagan.
program test
implicit none
type line_struct
integer :: width = 10
end type
type symbol_struct
integer :: typee = 313233
end type
type curve_struct
type (line_struct) line
type (symbol_struct) symbol
end type
type (curve_struct) curve(10)
namelist / params / curve
!
open (10, status="scratch")
write(10,*) "¶ms"
write(10,*) " curve(1)%symbol%typee = 1234"
write(10,*) "/"
rewind(10)
read (10, nml = params)
if (curve(1)%symbol%typee /= 1234) call abort
close(10)
end program
Patch:
Index: list_read.c
===================================================================
--- list_read.c (revision 164242)
+++ list_read.c (working copy)
@@ -2757,10 +2757,11 @@ get_name:
goto nml_err_ret;
}
- if (!component_flag)
+ if (*pprev_nl == NULL || !component_flag)
first_nl = nl;
root_nl = nl;
+
component_flag = 1;
c = next_char (dtp);