summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>2004-06-22 00:22:32 +0200
committerTobias Schlüter <tobi@gcc.gnu.org>2004-06-22 00:22:32 +0200
commitfa84120041353fa15ba2345e4442ec9e10ffc25b (patch)
treeb7d5e1b4fab9f3c7d2ba14953873091dcc16e31a
parent6263a8f6a597b54898d4865420e61c6368f67080 (diff)
downloadgcc-fa84120041353fa15ba2345e4442ec9e10ffc25b.tar.gz
re PR fortran/15511 (Warning about truncated lines does not follow the standard gcc error message format)
PR fortran/15511 * scanner.c (load_line): Don't truncate preprocessor lines. Reformat error message. (preprocessor_line): Issue warning in case of malformed preprocessor line. From-SVN: r83455
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/scanner.c38
2 files changed, 35 insertions, 11 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 4677f3921bf..41c9a90a780 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2004-06-21 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de
+
+ PR fortran/15511
+ * scanner.c (load_line): Don't truncate preprocessor lines.
+ Reformat error message.
+ (preprocessor_line): Issue warning in case of malformed
+ preprocessor line.
+
2004-06-21 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* resolve.c (resolve_symbol): Add comment in function body.
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index b280e1417ba..8b8f0b0295e 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -679,7 +679,7 @@ gfc_gobble_whitespace (void)
static void
load_line (FILE * input, char *buffer, char *filename, int linenum)
{
- int c, maxlen, i, trunc_flag;
+ int c, maxlen, i, trunc_flag, preprocessor_flag;
maxlen = (gfc_current_form == FORM_FREE)
? 132
@@ -687,6 +687,13 @@ load_line (FILE * input, char *buffer, char *filename, int linenum)
i = 0;
+ preprocessor_flag = 0;
+ c = fgetc (input);
+ if (c == '#')
+ /* Don't truncate preprocessor lines. */
+ preprocessor_flag = 1;
+ ungetc (c, input);
+
for (;;)
{
c = fgetc (input);
@@ -722,7 +729,7 @@ load_line (FILE * input, char *buffer, char *filename, int linenum)
*buffer++ = c;
i++;
- if (i >= maxlen)
+ if (i >= maxlen && !preprocessor_flag)
{ /* Truncate the rest of the line. */
trunc_flag = 1;
@@ -736,8 +743,8 @@ load_line (FILE * input, char *buffer, char *filename, int linenum)
&& trunc_flag
&& !gfc_is_whitespace (c))
{
- gfc_warning_now ("Line %d of %s is being truncated",
- linenum, filename);
+ gfc_warning_now ("%s:%d: Line is being truncated",
+ filename, linenum);
trunc_flag = 0;
}
}
@@ -789,19 +796,21 @@ preprocessor_line (char *c)
c++;
if (*c < '0' || *c > '9')
- {
- gfc_warning_now ("%s:%d Unknown preprocessor directive",
- current_file->filename, current_file->line);
- current_file->line++;
- return;
- }
+ goto bad_cpp_line;
line = atoi (c);
- c = strchr (c, ' ') + 2; /* Skip space and quote. */
+ c = strchr (c, ' ');
+ if (c == NULL)
+ /* Something we don't understand has happened. */
+ goto bad_cpp_line;
+ c += 2; /* Skip space and quote. */
filename = c;
c = strchr (c, '"'); /* Make filename end at quote. */
+ if (c == NULL)
+ /* Preprocessor line has no closing quote. */
+ goto bad_cpp_line;
*c++ = '\0';
/* Get flags. */
@@ -846,6 +855,13 @@ preprocessor_line (char *c)
current_file->filename = gfc_getmem (strlen (filename) + 1);
strcpy (current_file->filename, filename);
}
+
+ return;
+
+ bad_cpp_line:
+ gfc_warning_now ("%s:%d: Unknown preprocessor directive",
+ current_file->filename, current_file->line);
+ current_file->line++;
}