This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[PATCH] Fix PR14569
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>, fortran at gcc dot gnu dot org
- Date: Fri, 15 Apr 2005 21:59:09 +0200
- Subject: [PATCH] Fix PR14569
Removes line truncation warnings for comment lines and adds correct
location information to the remaining ones.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline and branch once it re-opens?
Thanks,
Richard.
2005-04-15 Richard Guenther <rguenth@gcc.gnu.org>
PR fortran/14569
* gfortran.h (gfc_linebuf): Add truncated field.
* parse.c (next_statement): Handle warning for truncated
lines.
* scanner.c (load_line): Return if line was truncated.
No longer warn for truncated lines. Remove unused parameters.
(load_file): Store load_line return value to linebuf.
(gfc_error_recovery): Do not advance line at the end.
Index: gfortran.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/gfortran.h,v
retrieving revision 1.64
diff -c -3 -p -r1.64 gfortran.h
*** gfortran.h 14 Apr 2005 16:29:31 -0000 1.64
--- gfortran.h 15 Apr 2005 19:04:41 -0000
*************** typedef struct gfc_linebuf
*** 481,486 ****
--- 481,488 ----
struct gfc_file *file;
struct gfc_linebuf *next;
+ int truncated;
+
char line[1];
} gfc_linebuf;
Index: parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/parse.c,v
retrieving revision 1.25
diff -c -3 -p -r1.25 parse.c
*** parse.c 23 Feb 2005 19:02:13 -0000 1.25
--- parse.c 15 Apr 2005 19:04:41 -0000
*************** next_statement (void)
*** 479,485 ****
gfc_buffer_error (1);
if (gfc_at_eol ())
! gfc_advance_line ();
gfc_skip_comments ();
--- 479,491 ----
gfc_buffer_error (1);
if (gfc_at_eol ())
! {
! if (gfc_option.warn_line_truncation
! && gfc_current_locus.lb->truncated)
! gfc_warning_now ("Line truncated at %C");
!
! gfc_advance_line ();
! }
gfc_skip_comments ();
Index: scanner.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/scanner.c,v
retrieving revision 1.16
diff -c -3 -p -r1.16 scanner.c
*** scanner.c 18 Jan 2005 12:11:54 -0000 1.16
--- scanner.c 15 Apr 2005 19:04:41 -0000
*************** gfc_error_recovery (void)
*** 631,651 ****
if (c == delim)
break;
if (c == '\n')
! goto done;
if (c == '\\')
{
c = next_char ();
if (c == '\n')
! goto done;
}
}
if (gfc_at_eof ())
break;
}
-
- done:
- if (c == '\n')
- gfc_advance_line ();
}
--- 631,647 ----
if (c == delim)
break;
if (c == '\n')
! return;
if (c == '\\')
{
c = next_char ();
if (c == '\n')
! return;
}
}
if (gfc_at_eof ())
break;
}
}
*************** gfc_gobble_whitespace (void)
*** 677,688 ****
need be.
In fixed mode, we expand a tab that occurs within the statement
label region to expand to spaces that leave the next character in
! the source region. */
! static void
! load_line (FILE * input, char **pbuf, char *filename, int linenum)
{
! int c, maxlen, i, trunc_flag, preprocessor_flag;
static int buflen = 0;
char *buffer;
--- 673,686 ----
need be.
In fixed mode, we expand a tab that occurs within the statement
label region to expand to spaces that leave the next character in
! the source region.
! load_line returns wether the line was truncated. */
! static int
! load_line (FILE * input, char **pbuf)
{
! int c, maxlen, i, preprocessor_flag;
! int trunc_flag = 0;
static int buflen = 0;
char *buffer;
*************** load_line (FILE * input, char **pbuf, ch
*** 767,781 ****
c = fgetc (input);
if (c == '\n' || c == EOF)
break;
-
- if (gfc_option.warn_line_truncation
- && trunc_flag
- && !gfc_is_whitespace (c))
- {
- gfc_warning_now ("%s:%d: Line is being truncated",
- filename, linenum);
- trunc_flag = 0;
- }
}
ungetc ('\n', input);
--- 765,770 ----
*************** load_line (FILE * input, char **pbuf, ch
*** 791,796 ****
--- 780,787 ----
*buffer++ = ' ';
*buffer = '\0';
+
+ return trunc_flag;
}
*************** load_file (char *filename, bool initial)
*** 1034,1040 ****
for (;;)
{
! load_line (input, &line, filename, current_file->line);
len = strlen (line);
if (feof (input) && len == 0)
--- 1025,1031 ----
for (;;)
{
! int trunc = load_line (input, &line);
len = strlen (line);
if (feof (input) && len == 0)
*************** load_file (char *filename, bool initial)
*** 1066,1071 ****
--- 1057,1063 ----
b->linenum = current_file->line++;
#endif
b->file = current_file;
+ b->truncated = trunc;
strcpy (b->line, line);
if (line_head == NULL)