Commit 1526c4b5 by Jerry DeLisle

re PR fortran/19261 (continuation character illegal as first non-blank character in statement)

2006-10-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/19261
	* scanner.c (load_line): Add checks for illegal use of '&' and issue
	warnings.  Issue errors with -pedantic.

From-SVN: r117733
parent 467f18f3
2006-10-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/19261
* scanner.c (load_line): Add checks for illegal use of '&' and issue
warnings. Issue errors with -pedantic.
2006-10-14 Paul Thomas <pault@gcc.gnu.org> 2006-10-14 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29371 PR fortran/29371
......
...@@ -940,7 +940,11 @@ gfc_gobble_whitespace (void) ...@@ -940,7 +940,11 @@ gfc_gobble_whitespace (void)
In fixed mode, we expand a tab that occurs within the statement In fixed mode, we expand a tab that occurs within the statement
label region to expand to spaces that leave the next character in label region to expand to spaces that leave the next character in
the source region. the source region.
load_line returns whether the line was truncated. */ load_line returns whether the line was truncated.
NOTE: The error machinery isn't available at this point, so we can't
easily report line and column numbers consistent with other
parts of gfortran. */
static int static int
load_line (FILE * input, char **pbuf, int *pbuflen) load_line (FILE * input, char **pbuf, int *pbuflen)
...@@ -948,6 +952,7 @@ load_line (FILE * input, char **pbuf, int *pbuflen) ...@@ -948,6 +952,7 @@ load_line (FILE * input, char **pbuf, int *pbuflen)
static int linenum = 0, current_line = 1; static int linenum = 0, current_line = 1;
int c, maxlen, i, preprocessor_flag, buflen = *pbuflen; int c, maxlen, i, preprocessor_flag, buflen = *pbuflen;
int trunc_flag = 0, seen_comment = 0; int trunc_flag = 0, seen_comment = 0;
int seen_printable = 0, seen_ampersand = 0;
char *buffer; char *buffer;
/* Determine the maximum allowed line length. /* Determine the maximum allowed line length.
...@@ -999,7 +1004,20 @@ load_line (FILE * input, char **pbuf, int *pbuflen) ...@@ -999,7 +1004,20 @@ load_line (FILE * input, char **pbuf, int *pbuflen)
if (c == EOF) if (c == EOF)
break; break;
if (c == '\n') if (c == '\n')
break; {
/* Check for illegal use of ampersand. See F95 Standard 3.3.1.3. */
if (gfc_current_form == FORM_FREE
&& !seen_printable && seen_ampersand)
{
if (pedantic)
gfc_error_now
("'&' not allowed by itself in line %d", current_line);
else
gfc_warning_now
("'&' not allowed by itself in line %d", current_line);
}
break;
}
if (c == '\r') if (c == '\r')
continue; /* Gobble characters. */ continue; /* Gobble characters. */
...@@ -1013,6 +1031,25 @@ load_line (FILE * input, char **pbuf, int *pbuflen) ...@@ -1013,6 +1031,25 @@ load_line (FILE * input, char **pbuf, int *pbuflen)
break; break;
} }
/* Check for illegal use of ampersand. See F95 Standard 3.3.1.3. */
if (c == '&')
seen_ampersand = 1;
if ((c != ' ' && c != '&' && c != '!') || (c == '!' && !seen_ampersand))
seen_printable = 1;
if (gfc_current_form == FORM_FREE
&& c == '!' && !seen_printable && seen_ampersand)
{
if (pedantic)
gfc_error_now (
"'&' not allowed by itself with comment in line %d", current_line);
else
gfc_warning_now (
"'&' not allowed by itself with comment in line %d", current_line);
seen_printable = 1;
}
/* Is this a fixed-form comment? */ /* Is this a fixed-form comment? */
if (gfc_current_form == FORM_FIXED && i == 0 if (gfc_current_form == FORM_FIXED && i == 0
&& (c == '*' || c == 'c' || c == 'd')) && (c == '*' || c == 'c' || c == 'd'))
...@@ -1020,9 +1057,6 @@ load_line (FILE * input, char **pbuf, int *pbuflen) ...@@ -1020,9 +1057,6 @@ load_line (FILE * input, char **pbuf, int *pbuflen)
if (gfc_current_form == FORM_FIXED && c == '\t' && i <= 6) if (gfc_current_form == FORM_FIXED && c == '\t' && i <= 6)
{ {
/* The error machinery isn't available at this point, so we can't
easily report line and column numbers consistent with other
parts of gfortran. */
if (!gfc_option.warn_tabs && seen_comment == 0 if (!gfc_option.warn_tabs && seen_comment == 0
&& current_line != linenum) && current_line != linenum)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment