This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] PR39229 No warning of truncated lines if a continuation line follows
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 29 Aug 2009 18:48:32 -0700
- Subject: Re: [patch, fortran] PR39229 No warning of truncated lines if a continuation line follows
- References: <4A986121.3040505@verizon.net>
Jerry DeLisle wrote:
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.
I found some more time to work on this. The attached patch is simplified from
the previous and I believe takes care of all the cases.
Regression tested on x86-64. Two test cases, one for free-form and one for
fixed-form.
OK to commit?
Regards,
Jerry
2009-08-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/39229
* scanner.c (next_char): Fix typo in comment.
(gfc_get_char_literal): Warn if truncate flag is set for both fixed and
free form source, adjusting error locus as needed.
* parse.c (next_fixed): Clear the truncate flag.
(next_statement): Remove truncate warning.
Index: scanner.c
===================================================================
--- scanner.c (revision 151156)
+++ scanner.c (working copy)
@@ -614,7 +614,7 @@ next_char (void)
/* Skip a comment. When we come here the parse pointer is positioned
immediately after the comment character. If we ever implement
- compiler directives withing comments, here is where we parse the
+ compiler directives within comments, here is where we parse the
directive. */
static void
@@ -1080,6 +1080,17 @@ restart:
}
}
+ /* Check to see if the continuation line was truncated. */
+ if (gfc_option.warn_line_truncation && gfc_current_locus.lb != NULL
+ && gfc_current_locus.lb->truncated)
+ {
+ int maxlen = gfc_option.free_line_length;
+ gfc_current_locus.lb->truncated = 0;
+ gfc_current_locus.nextc += maxlen;
+ gfc_warning_now ("Line truncated at %L", &gfc_current_locus);
+ gfc_current_locus.nextc -= maxlen;
+ }
+
/* Now find where it continues. First eat any comment lines. */
openmp_cond_flag = skip_free_comments ();
@@ -1158,6 +1169,14 @@ restart:
if (c != '\n')
goto done;
+ /* Check to see if the continuation line was truncated. */
+ if (gfc_option.warn_line_truncation && gfc_current_locus.lb != NULL
+ && gfc_current_locus.lb->truncated)
+ {
+ gfc_current_locus.lb->truncated = 0;
+ gfc_warning_now ("Line truncated at %L", &gfc_current_locus);
+ }
+
prev_openmp_flag = openmp_flag;
continue_flag = 1;
old_loc = gfc_current_locus;
Index: parse.c
===================================================================
--- parse.c (revision 151156)
+++ parse.c (working copy)
@@ -849,6 +849,8 @@ next_fixed (void)
blank_line:
if (digit_flag)
gfc_warning ("Ignoring statement label in empty statement at %C");
+
+ gfc_current_locus.lb->truncated = 0;
gfc_advance_line ();
return ST_NONE;
}
@@ -862,6 +864,7 @@ next_statement (void)
{
gfc_statement st;
locus old_locus;
+
gfc_new_block = NULL;
gfc_current_ns->old_cl_list = gfc_current_ns->cl_list;
@@ -871,15 +874,8 @@ next_statement (void)
gfc_buffer_error (1);
if (gfc_at_eol ())
- {
- if ((gfc_option.warn_line_truncation || gfc_current_form == FORM_FREE)
- && gfc_current_locus.lb
- && gfc_current_locus.lb->truncated)
- gfc_warning_now ("Line truncated at %C");
+ gfc_advance_line ();
- gfc_advance_line ();
- }
-
gfc_skip_comments ();
if (gfc_at_end ())
! { dg-do compile }
! { dg-options "-std=gnu -ffixed-form -Wline-truncation" }
! PR39229 No warning of truncated lines if a continuation line follows
! expected: no warning by default (as column 73+ is often used for )
! comments in fixed-form source code.
! however, with -wline-truncation there shall be a warning.
implicit none
call foo([11, 22, 33, 44, 55, 66, 770, 9900, 1100, 1100, 120], 12 warn
& , 'hello')
print *, min(35
1 , 25 warn
2 )
contains
subroutine foo(a,n,s)
integer :: a(*), n, i
character(len=*) :: s
do i = 1, n
print *, s, a(i)
end do
end subroutine foo
end
! { dg-warning "Line truncated" " " { target *-*-* } 8 }
! { dg-warning "Line truncated" " " { target *-*-* } 11 }
! { dg-do compile }
! { dg-options "-Wline-truncation -ffree-line-length-80" }
! PR39229 No warning of truncated lines if a continuation line follows
implicit none
call foo([11, 22, 33, 44, 55, 66, 770, 9900, 1100, 1100, 120],11,'hello') !no warn
print *, min(35 &
& , 25 ), " Explanation ! " warn
contains
subroutine foo(a,n,s)
integer :: a(*), n, i
character(len=*) :: s
do i = 1, n
print *, s, a(i)
end do
end subroutine foo
end
! { dg-warning "Line truncated" " " { target *-*-* } 8 }