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, fortran] Pr35882 Miscounted continuation lines when interspersed with data


:ADDPATCH fortran:

This patch takes care of the situation where we have intervening comments between continuation lines. The fixed form situation is a bit more complicated. Regardless, it amounts to updating the continue_line number for each case where comments are encountered.

Regression tested on x86-64. Patch includes updates to two test cases.

OK to commit?

Jerry

2008-04-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR fortran/35882
	* scanner.c (skip_fixed_comments): Update continue_line when comment is
	detected. (gfc_next_char_literal): Likewise.
Index: testsuite/gfortran.dg/continuation_5.f
===================================================================
--- testsuite/gfortran.dg/continuation_5.f	(revision 134473)
+++ testsuite/gfortran.dg/continuation_5.f	(working copy)
@@ -32,11 +32,19 @@
      c "7" // !  7
      c "8" // !  8
      c "9" // !  9
+!
+c
+*
+C
      c "0" // ! 10
      c "1" // ! 11
      c "2" // ! 12
      c "3" // ! 13
      c "4" // ! 14
+c
+ 
+ !
+                          !
      c "5" // ! 15
      c "6" // ! 16
      c "7" // ! 17
Index: testsuite/gfortran.dg/continuation_3.f90
===================================================================
--- testsuite/gfortran.dg/continuation_3.f90	(revision 134473)
+++ testsuite/gfortran.dg/continuation_3.f90	(working copy)
@@ -72,8 +72,12 @@ print *, &
        "7" // & ! 27
        "8" // & ! 28
        "9" // & ! 29
+!
+   !
        "0" // & ! 30
        "1" // & ! 31
+!
+!
        "2" // & ! 32
        "3" // & ! 33
        "4" // & ! 34
Index: fortran/scanner.c
===================================================================
--- fortran/scanner.c	(revision 134473)
+++ fortran/scanner.c	(working copy)
@@ -615,6 +615,10 @@ skip_fixed_comments (void)
 		!$|c$|*$ should be treated as 2 spaces if the characters
 		in columns 3 to 6 are valid fixed form label columns
 		characters.  */
+	  if (gfc_current_locus.lb != NULL
+	      && continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
+	    continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
+
 	  if (gfc_option.flag_openmp)
 	    {
 	      if (next_char () == '$')
@@ -700,6 +704,9 @@ skip_fixed_comments (void)
 
       if (col != 6 && c == '!')
 	{
+	  if (gfc_current_locus.lb != NULL
+	      && continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
+	    continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
 	  skip_comment_line ();
 	  continue;
 	}
@@ -821,12 +828,14 @@ restart:
 			     "statement at %C", gfc_option.max_continue_free);
 	    }
 	}
-      if (continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
-	continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
 
       /* Now find where it continues. First eat any comment lines.  */
       openmp_cond_flag = skip_free_comments ();
 
+      if (gfc_current_locus.lb != NULL
+	  && continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
+	continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
+
       if (prev_openmp_flag != openmp_flag)
 	{
 	  gfc_current_locus = old_loc;
@@ -945,7 +954,8 @@ restart:
 	    }
 	}
 
-      if (continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
+      if (gfc_current_locus.lb != NULL
+	  && continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
 	continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
     }
 

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