This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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, Fortran] PR 50109 - fix skipping multiple comment lines in namelists


The patch should be rather simple and self explaining.

Build and regtested on x86-64-linux.
OK for the trunk?

I wonder how far we should backport; the program is said to work in 4.1.2 and 4.2.5, but to fail in 4.3.6 up to the trunk. Oldest maintained GCC is 4.4.6. The patch is relatively simple, but as the long time between breakage and report shows, it does not seem to affect many users.

I think we should backport the patch at least to 4.6 and 4.5 , but one could also consider 4.4 or even 4.3. What do you think?

Tobias

PS: RHES 6 uses 4.4, SLES uses 4.3 with 4.5 as technical preview.
2011-08-18  Tobias Burnus  <burnus@net-b.de>

	PR fortran/50109
	* io/list_read.c (eat_separator): Fix skipping over "!" lines.

2011-08-18  Tobias Burnus  <burnus@net-b.de>

	PR fortran/50109
	* gfortran.dg/namelist_73.f90: New.

diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 01272d0..11a35c9 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -351,16 +351,7 @@ eat_separator (st_parameter_dt *dtp)
 		  err = eat_line (dtp);
 		  if (err)
 		    return err;
-		  if ((c = next_char (dtp)) == EOF)
-		    return LIBERROR_END;
-		  if (c == '!')
-		    {
-		      err = eat_line (dtp);
-		      if (err)
-			return err;
-		      if ((c = next_char (dtp)) == EOF)
-			return LIBERROR_END;
-		    }
+		  c = '\n';
 		}
 	    }
 	  while (c == '\n' || c == '\r' || c == ' ' || c == '\t');
--- /dev/null	2011-08-17 07:24:12.871882230 +0200
+++ gcc/gcc/testsuite/gfortran.dg/namelist_73.f90	2011-08-18 11:40:28.000000000 +0200
@@ -0,0 +1,28 @@
+! { dg-do run }
+!
+! PR fortran/50109
+!
+! Contributed by Jim Hanson
+!
+      program namelist_test
+
+      integer nfp
+      namelist /indata/ nfp
+
+      nfp = 99
+      open(unit=4, status='scratch')
+      write(4,'(a)') '$indata'
+      write(4,'(a)') 'NFP = 5,'
+      write(4,'(a)') "!  "
+      write(4,'(a)') "! "
+      write(4,'(a)') "!  "
+      write(4,'(a)') '/'
+
+      rewind(4)
+      read (4,nml=indata)
+      close(4)
+
+!      write(*,*) nfp
+      if (nfp /= 5) call abort()
+
+      end

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