]> gcc.gnu.org Git - gcc.git/commitdiff
re PR fortran/14569 ([4.0 only] should not warn about truncated comment lines)
authorRichard Guenther <rguenth@gcc.gnu.org>
Fri, 15 Apr 2005 20:35:26 +0000 (20:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 15 Apr 2005 20:35:26 +0000 (20:35 +0000)
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.

From-SVN: r98210

gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/parse.c
gcc/fortran/scanner.c

index e1b1097812874b71988d36bbd3831b8a11275e5c..b3f0b1c3b170475ee27e7c2bd9bd21bd91d960fd 100644 (file)
@@ -1,3 +1,14 @@
+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.
+
 2005-04-14  Steven G. Kargl  <kargls@comcast.net>
 
        * gfortran.h (gfc_real_info): Add subnormal struct member.
index 330cedae26920cec5a82f384ebd2c64f9c7a2175..c266d589c0c2547e0e162267ea423f993c6c44d0 100644 (file)
@@ -481,6 +481,8 @@ typedef struct gfc_linebuf
   struct gfc_file *file;
   struct gfc_linebuf *next;
 
+  int truncated;
+
   char line[1];
 } gfc_linebuf;
 
index a3f0ac19539ded0fd7a9e6fa2b96c51327a5f073..94bf6d0d28d7fa27bbd1cb14907471c56a1fa8e5 100644 (file)
@@ -479,7 +479,13 @@ next_statement (void)
       gfc_buffer_error (1);
 
       if (gfc_at_eol ())
-       gfc_advance_line ();
+       {
+         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 cab85f4dcfa5bc4f028dbf1d8a9f4e98367e7f2f..5748ef38934cbb9035803fa8259053eeb75e08dc 100644 (file)
@@ -631,21 +631,17 @@ gfc_error_recovery (void)
          if (c == delim)
            break;
          if (c == '\n')
-           goto done;
+           return;
          if (c == '\\')
            {
              c = next_char ();
              if (c == '\n')
-               goto done;
+               return;
            }
        }
       if (gfc_at_eof ())
        break;
     }
-
-done:
-  if (c == '\n')
-    gfc_advance_line ();
 }
 
 
@@ -677,12 +673,14 @@ gfc_gobble_whitespace (void)
    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.  */
+   the source region.
+   load_line returns wether the line was truncated.  */
 
-static void
-load_line (FILE * input, char **pbuf, char *filename, int linenum)
+static int
+load_line (FILE * input, char **pbuf)
 {
-  int c, maxlen, i, trunc_flag, preprocessor_flag;
+  int c, maxlen, i, preprocessor_flag;
+  int trunc_flag = 0;
   static int buflen = 0;
   char *buffer;
 
@@ -767,15 +765,6 @@ load_line (FILE * input, char **pbuf, char *filename, int linenum)
              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);
@@ -791,6 +780,8 @@ load_line (FILE * input, char **pbuf, char *filename, int linenum)
       *buffer++ = ' ';
 
   *buffer = '\0';
+
+  return trunc_flag;
 }
 
 
@@ -1034,7 +1025,7 @@ load_file (char *filename, bool initial)
 
   for (;;) 
     {
-      load_line (input, &line, filename, current_file->line);
+      int trunc = load_line (input, &line);
 
       len = strlen (line);
       if (feof (input) && len == 0)
@@ -1066,6 +1057,7 @@ load_file (char *filename, bool initial)
       b->linenum = current_file->line++;
 #endif
       b->file = current_file;
+      b->truncated = trunc;
       strcpy (b->line, line);
 
       if (line_head == NULL)
This page took 0.135147 seconds and 5 git commands to generate.