public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] PR35882 Miscounted continuation lines when  interspersed with data
@ 2008-04-14  7:02 Jerry DeLisle
  0 siblings, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2008-04-14  7:02 UTC (permalink / raw)
  To: Fortran List; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

This patch is obvious and simple and I will commit shortly with the new
test case.  I am changing gfortran default behavior to warn on -pedantic
or -std=f2003 if the continuation line count exceeds 255 and warn for 19
and 39 for -std=f95.

Regression tested on x86-64-gnu-linux.

Best regards,

Jerry

2008-04-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
	    Tobias Burnus  <burnus@net-b.de>

	PR fortran/35882
	* options.c (gfc_init_options): Set the default maximum continuation
	lines to 255 for both free and fixed form source for warnings.
	(gfc_handle_option): Set -std=f95 fixed form max continuations to 19 and
	the -std=f95 free form max continuations to 39 for warnings.
	* scanner.c (gfc_next_char_literal): Adjust the current_line number only
	if it is less than the current locus.




[-- Attachment #2: pr35882.diff --]
[-- Type: text/x-patch, Size: 3287 bytes --]

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 134245)
+++ ChangeLog	(working copy)
@@ -1,5 +1,15 @@
 2008-04-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
+	PR fortran/35882
+	* options.c (gfc_init_options): Set the default maximum continuation
+	lines to 255 for both free and fixed form source for warnings.
+	(gfc_handle_option): Set -std=f95 fixed form max continuations to 19 and
+	the -std=f95 free form max continuations to 39 for warnings.
+	* scanner.c (gfc_next_char_literal): Adjust the current_line number only
+	if it is less than the current locus. Delete pedantic condition.
+
+2008-04-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
 	PR fortran/25829 28655
 	* io.c (io_tag): Add new tags for decimal, encoding, asynchronous,
 	round, sign, and id. (match_open_element): Match new tags.
Index: scanner.c
===================================================================
--- scanner.c	(revision 134245)
+++ scanner.c	(working copy)
@@ -821,7 +821,8 @@ restart:
 			     "statement at %C", gfc_option.max_continue_free);
 	    }
 	}
-      continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
+      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 ();
Index: options.c
===================================================================
--- options.c	(revision 134245)
+++ options.c	(working copy)
@@ -58,8 +58,8 @@ gfc_init_options (unsigned int argc ATTR
   gfc_option.source_form = FORM_UNKNOWN;
   gfc_option.fixed_line_length = 72;
   gfc_option.free_line_length = 132;
-  gfc_option.max_continue_fixed = 19;
-  gfc_option.max_continue_free = 39;
+  gfc_option.max_continue_fixed = 255;
+  gfc_option.max_continue_free = 255;
   gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
   gfc_option.max_subrecord_length = 0;
   gfc_option.convert = GFC_CONVERT_NATIVE;
@@ -733,6 +733,8 @@ gfc_handle_option (size_t scode, const c
     case OPT_std_f95:
       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95 | GFC_STD_F77;
       gfc_option.warn_std = GFC_STD_F95_OBS;
+      gfc_option.max_continue_fixed = 19;
+      gfc_option.max_continue_free = 39;
       gfc_option.max_identifier_length = 31;
       gfc_option.warn_ampersand = 1;
       gfc_option.warn_tabs = 0;
@@ -742,8 +744,6 @@ gfc_handle_option (size_t scode, const c
       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
 	| GFC_STD_F2003 | GFC_STD_F95;
       gfc_option.warn_std = GFC_STD_F95_OBS;
-      gfc_option.max_continue_fixed = 255;
-      gfc_option.max_continue_free = 255;
       gfc_option.max_identifier_length = 63;
       gfc_option.warn_ampersand = 1;
       gfc_option.warn_tabs = 0;
@@ -753,8 +753,6 @@ gfc_handle_option (size_t scode, const c
       gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 
 	| GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008;
       gfc_option.warn_std = GFC_STD_F95_OBS;
-      gfc_option.max_continue_fixed = 255;
-      gfc_option.max_continue_free = 255;
       gfc_option.max_identifier_length = 63;
       gfc_option.warn_ampersand = 1;
       gfc_option.warn_tabs = 0;


[-- Attachment #3: continuation_10.f90 --]
[-- Type: text/x-fortran, Size: 1092 bytes --]

! { dg-do compile }
! { dg-options -std=f95 }
! PR35882 Miscounted continuation lines when interspersed with data
program test_mod
   implicit none

   integer, dimension(50) :: array

   array = 1

   print "(a, i8)", &
      "Line 1", &
      array(2), &
      "Line 3", &
      array(4), &
      "Line 5", &
      array(6), &
      "Line 7", &
      array(8), &
      "Line 9", &
      array(10), &
      "Line 11", &
      array(12), &
      "Line 13", &
      array(14), &
      "Line 15", &
      array(16), &
      "Line 17", &
      array(18), &
      "Line 19", &
      array(20), &
      "Line 21", &
      array(22), &
      "Line 23", &
      array(24), &
      "Line 25", &
      array(26), &
      "Line 27", &
      array(28), &
      "Line 29", &
      array(30), &
      "Line 31", &
      array(32), &
      "Line 33", &
      array(34), &
      "Line 35", &
      array(36), &
      "Line 37", &
      array(38), &
      "Line 39", &
      array(40), & ! { dg-warning "Limit of 39 continuations exceeded" }
      "Line 41", &
      array(42), &
      "Line 43"
end program

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch, fortran] Pr35882 Miscounted continuation lines when  interspersed with data
  2008-04-20 21:16 [patch, fortran] Pr35882 " Jerry DeLisle
@ 2008-04-21  3:15 ` FX
  0 siblings, 0 replies; 3+ messages in thread
From: FX @ 2008-04-21  3:15 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: Fortran List, gcc-patches

> 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.

OK

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch, fortran] Pr35882 Miscounted continuation lines when  interspersed with data
@ 2008-04-20 21:16 Jerry DeLisle
  2008-04-21  3:15 ` FX
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry DeLisle @ 2008-04-20 21:16 UTC (permalink / raw)
  To: Fortran List; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 571 bytes --]

: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.

[-- Attachment #2: pr35882-2.diff --]
[-- Type: text/x-patch, Size: 2794 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-20 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-14  7:02 [patch, fortran] PR35882 Miscounted continuation lines when interspersed with data Jerry DeLisle
2008-04-20 21:16 [patch, fortran] Pr35882 " Jerry DeLisle
2008-04-21  3:15 ` FX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).