[patch, fortran] PR39229 No warning of truncated lines if a continuation line follows

Jerry DeLisle jvdelisle@verizon.net
Sat Aug 29 08:10:00 GMT 2009


Hi folks,

The attached patch changes the approach to handling truncation warnings.
   One of the problems we have is that the truncation is detected at the
scanner level and the truncation flag was being cleared if a comment was
found.  Unfortunately, at that level, the error handling mechanisms such
as current locus are not available yet.  However we can read check the
compile options.

This patch puts the check for -Wline_truncation at the scanner level at
the point of detecting truncation.  The truncation flag is then allowed
to be handed up to the parse level where it is checked at each call to
next statement.  At that point the error infrastructure is working and
we use it to get a locus on it.  I temporarily adjusted the locus to the
  maxval of the line which is where the truncation occurs before
issueing the warning, and then adjust it back.

[aside:  I see enough instances where I have used this trick with
offsetting the locus that I plan to introduce a new function to just do
this and always leave the locus where it was found.  This will give us a
consistent approach to fine tuning the error loci as we move forward.  I
will do that as a separate patch.]

Regarding the test case.  You may notice that since line 10 is continued to line 
  11, next_statement does not see the truncation of line 11 because on its next 
call, it has moved on to line 12.  This means that this patch is a vast 
improvement but not ideal.  I would like to get this much in for now and will 
leave the PR open for now while I study the situation some more.

Regression tested on x86-64.

OK for trunk.

Regards,

Jerry

2009-08-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/39229
	* scanner.c (next_char): Fix typo in comment.
	(restart:): Don't clear truncate flag.
	(load_line): Set seen_comment for '!'. Set truncation flag only if
	option -Wline-truncation is given.
	* parse.c (next_statement): Issue a warning if the truncate flag is set.
	Remember to adjust the locus for a meaningful message.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr39229.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090829/04978868/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: line_length_3.f
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090829/04978868/attachment-0001.ksh>


More information about the Fortran mailing list