Patchwork [libgfortran] PR45532 gfortran namelist read error

login
register
mail settings
Submitter Jerry DeLisle
Date Sept. 14, 2010, 4:21 a.m.
Message ID <4C8EF862.20204@frontier.com>
Download mbox | patch
Permalink /patch/64666/
State New
Headers show

Comments

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.

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,*) "&params"
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:

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