+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>
* module.c (use_iso_fortran_env_module): Fix standard check.
if (u != FMT_POSINT)
{
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),
&format_locus);
saved_token = u;
- goto finished;
+ goto fail;
}
u = format_lex ();
format_locus.nextc += format_string_pos;
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),
&format_locus);
saved_token = u;
- goto finished;
+ goto fail;
}
else
gfc_warning ("Period required in format "
gfc_warning ("The H format specifier at %L is"
" a Fortran 95 deleted feature", &format_locus);
}
-
if (mode == MODE_STRING)
{
format_string += value;
format_length -= value;
+ format_string_pos += repeat;
}
else
{
static gfc_try
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)
return SUCCESS;
format string that has been calculated, but that's probably not worth the
effort. */
format_locus = e->where;
-
- return check_format (is_input);
+ rv = 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;
}