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]

Re: [Patch, fortran] PR19262 more than thirty-nine continuation lines should issue a std-warn


Jerry DeLisle wrote:
Jerry DeLisle wrote:
PING, this fixes PR19260 and PR19262. I have a patch in the works for PR19261 as well, but it is ugly and I don't like it yet. PR19261 is more subtle then one would think.

So I would like to get this patch here committed first.

I just realized I left the gfortran.h portion of this patch out. I will retest and send the corrected patch when done.

Sorry,

Jerry

Here is the corrected patch.

Jerry

Index: gfortran.h
===================================================================
*** gfortran.h	(revision 117348)
--- gfortran.h	(working copy)
*************** typedef struct
*** 1613,1618 ****
--- 1613,1620 ----
       emits a fatal error.  */
    int fixed_line_length; /* maximum line length in fixed-form.  */
    int free_line_length; /* maximum line length in free-form.  */
+   int max_continue_fixed;
+   int max_continue_free;
    int max_identifier_length;
    int verbose;
  
Index: scanner.c
===================================================================
*** scanner.c	(revision 117348)
--- scanner.c	(working copy)
*************** static gfc_directorylist *include_dirs;
*** 61,66 ****
--- 61,67 ----
  static gfc_file *file_head, *current_file;
  
  static int continue_flag, end_flag, openmp_flag;
+ static int continue_count, continue_line;
  static locus openmp_locus;
  
  gfc_source_form gfc_current_form;
*************** const char *gfc_source_file;
*** 71,76 ****
--- 72,78 ----
  static FILE *gfc_src_file;
  static char *gfc_src_preprocessor_lines[2];
  
+ extern int pedantic;
  
  /* Main scanner initialization.  */
  
*************** gfc_scanner_init_1 (void)
*** 81,86 ****
--- 83,91 ----
    line_head = NULL;
    line_tail = NULL;
  
+   continue_count = 0;
+   continue_line = 0;
+ 
    end_flag = 0;
  }
  
*************** gfc_next_char_literal (int in_string)
*** 585,591 ****
  restart:
    c = next_char ();
    if (gfc_at_end ())
!     return c;
  
    if (gfc_current_form == FORM_FREE)
      {
--- 590,599 ----
  restart:
    c = next_char ();
    if (gfc_at_end ())
!     {
!       continue_count = 0;
!       return c;
!     }
  
    if (gfc_current_form == FORM_FREE)
      {
*************** restart:
*** 644,651 ****
        else
  	gfc_advance_line ();
  
!       /* We've got a continuation line and need to find where it continues.
! 	 First eat any comment lines.  */
        gfc_skip_comments ();
  
        if (prev_openmp_flag != openmp_flag)
--- 652,673 ----
        else
  	gfc_advance_line ();
  
!       /* We've got a continuation line.  If we are on the very next line after
! 	 the last continuation, increment the continuation line count and
! 	 check whether the limit has been exceeded.  */
!       if (gfc_current_locus.lb->linenum == continue_line + 1)
! 	{
! 	  if (++continue_count == gfc_option.max_continue_free)
! 	    {
! 	      if (gfc_notification_std (GFC_STD_GNU)
! 		  || pedantic)
! 		gfc_warning ("Limit of %d continuations exceeded in statement at %C",
! 			      gfc_option.max_continue_free);
! 	    }
! 	}
!       continue_line = gfc_current_locus.lb->linenum;
! 
!       /* Now find where it continues. First eat any comment lines.  */
        gfc_skip_comments ();
  
        if (prev_openmp_flag != openmp_flag)
*************** restart:
*** 681,690 ****
  
        if (c != '&')
  	{
! 	  if (in_string && gfc_option.warn_ampersand)
! 	    gfc_warning ("Missing '&' in continued character constant at %C");
! 
! 	  gfc_current_locus.nextc--;
  	}
      }
    else
--- 703,720 ----
  
        if (c != '&')
  	{
! 	  if (in_string)
! 	    {
! 	      if (gfc_option.warn_ampersand)
! 		gfc_warning_now ("Missing '&' in continued character constant at %C");
! 	      gfc_current_locus.nextc--;
! 	    }
! 	  else
! 	    {
! 	      c = ' ';
! 	      gfc_current_locus = old_loc;
! 	      goto done;
! 	    }
  	}
      }
    else
*************** restart:
*** 738,743 ****
--- 768,790 ----
        c = next_char ();
        if (c == '0' || c == ' ' || c == '\n')
  	goto not_continuation;
+ 
+       /* We've got a continuation line.  If we are on the very next line after
+ 	 the last continuation, increment the continuation line count and
+ 	 check whether the limit has been exceeded.  */
+       if (gfc_current_locus.lb->linenum == continue_line + 1)
+ 	{
+ 	  if (++continue_count == gfc_option.max_continue_fixed)
+ 	    {
+ 	      if (gfc_notification_std (GFC_STD_GNU)
+ 		  || pedantic)
+ 		gfc_warning ("Limit of %d continuations exceeded in statement at %C",
+ 			      gfc_option.max_continue_fixed);
+ 	    }
+ 	}
+ 
+       if (continue_line < gfc_current_locus.lb->linenum)
+ 	continue_line = gfc_current_locus.lb->linenum;
      }
  
    /* Ready to read first character of continuation line, which might
*************** not_continuation:
*** 749,754 ****
--- 796,803 ----
    gfc_current_locus = old_loc;
  
  done:
+   if (c == '\n')
+     continue_count = 0;
    continue_flag = 0;
    return c;
  }
Index: options.c
===================================================================
*** options.c	(revision 117348)
--- options.c	(working copy)
*************** gfc_init_options (unsigned int argc ATTR
*** 48,53 ****
--- 48,55 ----
    gfc_option.source_form = FORM_UNKNOWN;
    gfc_option.fixed_line_length = -1;
    gfc_option.free_line_length = -1;
+   gfc_option.max_continue_fixed = 19;
+   gfc_option.max_continue_free = 39;
    gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
    gfc_option.verbose = 0;
  
*************** gfc_handle_option (size_t scode, const c
*** 586,591 ****
--- 588,595 ----
        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;
        break;

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