Commit d0a2c5a9 by Bud Davis Committed by Jerry DeLisle

re PR fortran/28039 (Warn when ignoring extra characters in the format specification)

2010-04-08  Bud Davis  <bdavis9659@sbcglobal.net>

	PR fortran/28039
	* io.c (check_format_string):  Added check for additional non 
	blank characters after the format string was successfully 
	parsed.
	* io.c (check_format): Changed the error messages for positive
	int required and period required to drop through the error logic
	and report with gfc_error instead of gfc_error_now.  Corrected
	format postion for hollerith strings.

From-SVN: r158147
parent c02105be
2010-04-08 Bud Davis <bdavis9659@sbcglobal.net>
PR fortran/28039
* io.c (check_format_string): Added check for additional non
blank characters after the format string was successfully
parsed.
* io.c (check_format): Changed the error messages for positive
int required and period required to drop through the error logic
and report with gfc_error instead of gfc_error_now. Corrected
format postion for hollerith strings.
2010-04-08 Tobias Burnus <burnus@net-b.de> 2010-04-08 Tobias Burnus <burnus@net-b.de>
* module.c (use_iso_fortran_env_module): Fix standard check. * module.c (use_iso_fortran_env_module): Fix standard check.
......
...@@ -850,11 +850,11 @@ data_desc: ...@@ -850,11 +850,11 @@ data_desc:
if (u != FMT_POSINT) if (u != FMT_POSINT)
{ {
format_locus.nextc += format_string_pos; format_locus.nextc += format_string_pos;
gfc_error_now ("Positive width required in format " gfc_error ("Positive width required in format "
"specifier %s at %L", token_to_string (t), "specifier %s at %L", token_to_string (t),
&format_locus); &format_locus);
saved_token = u; saved_token = u;
goto finished; goto fail;
} }
u = format_lex (); u = format_lex ();
...@@ -866,11 +866,11 @@ data_desc: ...@@ -866,11 +866,11 @@ data_desc:
format_locus.nextc += format_string_pos; format_locus.nextc += format_string_pos;
if (gfc_option.warn_std != 0) if (gfc_option.warn_std != 0)
{ {
gfc_error_now ("Period required in format " gfc_error ("Period required in format "
"specifier %s at %L", token_to_string (t), "specifier %s at %L", token_to_string (t),
&format_locus); &format_locus);
saved_token = u; saved_token = u;
goto finished; goto fail;
} }
else else
gfc_warning ("Period required in format " gfc_warning ("Period required in format "
...@@ -970,11 +970,11 @@ data_desc: ...@@ -970,11 +970,11 @@ data_desc:
gfc_warning ("The H format specifier at %L is" gfc_warning ("The H format specifier at %L is"
" a Fortran 95 deleted feature", &format_locus); " a Fortran 95 deleted feature", &format_locus);
} }
if (mode == MODE_STRING) if (mode == MODE_STRING)
{ {
format_string += value; format_string += value;
format_length -= value; format_length -= value;
format_string_pos += repeat;
} }
else else
{ {
...@@ -1152,6 +1152,8 @@ finished: ...@@ -1152,6 +1152,8 @@ finished:
static gfc_try static gfc_try
check_format_string (gfc_expr *e, bool is_input) check_format_string (gfc_expr *e, bool is_input)
{ {
gfc_try rv;
int i;
if (!e || e->ts.type != BT_CHARACTER || e->expr_type != EXPR_CONSTANT) if (!e || e->ts.type != BT_CHARACTER || e->expr_type != EXPR_CONSTANT)
return SUCCESS; return SUCCESS;
...@@ -1162,8 +1164,20 @@ check_format_string (gfc_expr *e, bool is_input) ...@@ -1162,8 +1164,20 @@ check_format_string (gfc_expr *e, bool is_input)
format string that has been calculated, but that's probably not worth the format string that has been calculated, but that's probably not worth the
effort. */ effort. */
format_locus = e->where; format_locus = e->where;
rv = check_format (is_input);
return check_format (is_input); /* check for extraneous characters at the end of an otherwise valid format
string, like '(A10,I3)F5'
start at the end and move back to the last character processed,
spaces are OK */
if (rv == SUCCESS && e->value.character.length > format_string_pos)
for (i=e->value.character.length-1;i>format_string_pos-1;i--)
if (e->value.character.string[i] != ' ')
{
format_locus.nextc += format_length + 1;
gfc_warning ("Extraneous characters in format at %L", &format_locus);
break;
}
return rv;
} }
......
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