This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]