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] PR19260 & not required when splitting a token in continuation


:ADDPATCH fortran:

The attached patch improves handling of continuations.

i) It is not perfect. In the case of splitting tokens, it will allow the matchers to flag an error for all cases except where the token continues on the first character of the next line. I have not figured out how to test for that yet.

ii) I don't set -Wampersand if -pedantic so that a whole bunch of code does not give a warning when the '&' is missing on the continued line. When -Wall or -Wampersand are set, all cases of missing '&' are flagged with a warning.

Regression tested. Modified test continuation.f90 and renamed it continuation_1.f90. Added new test case continuation_2.f90

OK for trunk?

Regards,

Jerry

2006-09-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR fortran/19260
	* scanner.c (gfc_next_char_literal): Add check for missing '&'
	and set locus to old_locus.
	* options.c (gfc_post_options): Don't set Wampersand when pedantic.


Index: scanner.c
===================================================================
*** scanner.c	(revision 117065)
--- scanner.c	(working copy)
*************** restart:
*** 679,690 ****
  	    c = next_char ();
  	}
  
!       if (c != '&')
  	{
! 	  if (in_string && gfc_option.warn_ampersand)
! 	    gfc_warning ("Missing '&' in continued character constant at %C");
! 
! 	  gfc_current_locus.nextc--;
  	}
      }
    else
--- 679,698 ----
  	    c = next_char ();
  	}
  
!       if (c != '&' )
  	{
! 	  if (in_string)
! 	    {
! 	      if (gfc_option.warn_ampersand)
! 		gfc_warning ("Missing '&' in continued character constant at %C");
! 	      gfc_current_locus.nextc--;
! 	    }
! 	  else
! 	    {
! 	      if (gfc_option.warn_ampersand)
! 		gfc_warning ("Missing '&' in continuation at %C");
! 	      gfc_current_locus = old_loc;
! 	    }
  	}
      }
    else
Index: options.c
===================================================================
*** options.c	(revision 117065)
--- options.c	(working copy)
*************** gfc_post_options (const char **pfilename
*** 278,286 ****
    if (!gfc_option.flag_automatic)
      gfc_option.flag_max_stack_var_size = 0;
    
-   if (pedantic)
-     gfc_option.warn_ampersand = 1;
- 
    if (gfc_option.flag_all_intrinsics)
      gfc_option.warn_nonstd_intrinsics = 0;
  
--- 278,283 ----
! { dg-do run }
! { dg-options -Wampersand }
! PR 19101  Test line continuations and spaces.  Note: the missing ampersand
! before "world" is non standard default behavior.  Use -std=f95, -std=f2003,
! -pedantic, -Wall, or -Wampersand to catch this error
! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>.
program main
  character (len=40) &
  c                 ! { dg-warning "Warning: Missing '&' " }
  c = "Hello, &
         world!"    ! { dg-warning "Warning: Missing '&' " }
  if (c.ne.&
  "Hello, world!")&
call abort()        ! { dg-warning "Warning: Missing '&' " }
end program main

! { dg-do compile }
! PR 19260  Test line continuations and spaces.
! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>.
x = si&
n(3.14159/2)
y = co&  ! { dg-error "Unclassifiable statement" }
 s(3.14159/2)
end

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