From 3858668b7f79b15e2225861184fee21aca855066 Mon Sep 17 00:00:00 2001 From: rguenth Date: Sun, 17 Apr 2005 11:56:30 +0000 Subject: [PATCH] 2005-04-17 Richard Guenther * scanner.c (gfc_next_char_literal): Reset truncation flag for lines ending in a comment for both fixed and free form. (load_line): Do not set truncated flag if only truncating the EOL marker. * gfortran.dg/wtruncate.f: New testcase. * gfortran.dg/wtruncate.f90: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98269 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/scanner.c | 10 ++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/wtruncate.f | 10 ++++++++++ gcc/testsuite/gfortran.dg/wtruncate.f90 | 10 ++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/wtruncate.f create mode 100644 gcc/testsuite/gfortran.dg/wtruncate.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b3f0b1c..5864697 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2005-04-17 Richard Guenther + + * scanner.c (gfc_next_char_literal): Reset truncation flag + for lines ending in a comment for both fixed and free form. + (load_line): Do not set truncated flag if only truncating + the EOL marker. + 2005-04-15 Richard Guenther PR fortran/14569 diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 5748ef3..69fa3a1 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -458,6 +458,9 @@ restart: } while (c != '\n'); + /* Avoid truncation warnings for comment ending lines. */ + gfc_current_locus.lb->truncated = 0; + goto done; } @@ -525,6 +528,9 @@ restart: c = next_char (); } while (c != '\n'); + + /* Avoid truncation warnings for comment ending lines. */ + gfc_current_locus.lb->truncated = 0; } if (c != '\n') @@ -758,13 +764,13 @@ load_line (FILE * input, char **pbuf) else if (i >= buflen) { /* Truncate the rest of the line. */ - trunc_flag = 1; - for (;;) { c = fgetc (input); if (c == '\n' || c == EOF) break; + + trunc_flag = 1; } ungetc ('\n', input); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9b274d..023ccdd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-04-17 Richard Guenther + + * gfortran.dg/wtruncate.f: New testcase. + * gfortran.dg/wtruncate.f90: New testcase. + 2005-04-16 Mark Mitchell PR c++/21025 diff --git a/gcc/testsuite/gfortran.dg/wtruncate.f b/gcc/testsuite/gfortran.dg/wtruncate.f new file mode 100644 index 0000000..b7cac5d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/wtruncate.f @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-Wall" } + +! This long comment line should not trigger a line-truncation warning with -Wall + + PROGRAM foo + WRITE (*,*) "Test" ! Neither this comment which exceeds the 72 character limit, too + WRITE (*,*) "This exactly 72 character long soruce line not, too." + END + diff --git a/gcc/testsuite/gfortran.dg/wtruncate.f90 b/gcc/testsuite/gfortran.dg/wtruncate.f90 new file mode 100644 index 0000000..49b07d2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/wtruncate.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-Wall" } + +! This long comment line should not trigger a line-truncation warning with -Wall even for free-form 132 character line limit (blah blah) + + PROGRAM foo + WRITE (*,*) "Test" ! Neither this comment which exceeds the 132 character limit with some random words, too (blah blah) + WRITE (*,*) "This exactly 132 character long soruce line not, too. How can people fill 132 characters without sensless stuff" + END + -- 2.7.4