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


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.



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;

! { 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

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