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


:REVIEWMAIL:

The attached patch reflects addressing Tobias' comments and produces the syntax error for split tokens and warning for missing '&' in continued character constants.

The warning behavior is left as is based on previous discussions on the list quite a while ago. The default behavior for a character constant is to continue just before the beginning of the non-whitespace on the next line and warn with -Wall, -Wampersand, -std=f95, -std=f2003, and -pedantic.

Regression tested.

OK for trunk?

Jerry

2006-09-21 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 when not scanning a character literal.


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
! 	    {
! 	      c = ' ';
! 	      gfc_current_locus = old_loc;
! 	      goto done;
! 	    }
  	}
      }
    else
! { 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
  c = "Hello, &
         world!" ! { dg-warning "Warning: Missing '&' in continued character constant" }
  if (c.ne.&
                                   "Hello, world!")&
                               call abort();end program main

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

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