[libgfortran] PR45532 gfortran namelist read error

Message ID 4C8EF862.20204@frontier.com
State New
Headers show

Commit Message

Jerry DeLisle Sept. 14, 2010, 4:21 a.m.
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.



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,*) "&params"
write(10,*) " curve(1)%symbol%typee = 1234"
write(10,*) "/"
read (10, nml = params)
if (curve(1)%symbol%typee /= 1234) call abort
end program



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);