+2007-06-29 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/32483
+ * io.c (format_lex): Fix FMT_ZERO.
+ (check_format,check_format_string,gfc_match_format,
+ check_io_constraints) Additional checking for READ.
+
2007-06-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR other/31400
do
{
c = next_char_not_space ();
- if (c != '0')
- zflag = 0;
if (ISDIGIT (c))
- value = 10 * value + c - '0';
+ {
+ value = 10 * value + c - '0';
+ if (c != '0')
+ zflag = 0;
+ }
}
while (ISDIGIT (c));
means that the warning message is a little less than great. */
static try
-check_format (void)
+check_format (bool is_input)
{
const char *posint_required = _("Positive width required");
const char *nonneg_required = _("Nonnegative width required");
error = nonneg_required;
goto syntax;
}
+ else if (is_input && t == FMT_ZERO)
+ {
+ error = posint_required;
+ goto syntax;
+ }
t = format_lex ();
if (t != FMT_PERIOD)
error = nonneg_required;
goto syntax;
}
+ else if (is_input && t == FMT_ZERO)
+ {
+ error = posint_required;
+ goto syntax;
+ }
t = format_lex ();
if (t != FMT_PERIOD)
like a format string. */
static void
-check_format_string (gfc_expr *e)
+check_format_string (gfc_expr *e, bool is_input)
{
mode = MODE_STRING;
format_string = e->value.character.string;
- check_format ();
+ check_format (is_input);
}
start = gfc_current_locus;
- if (check_format () == FAILURE)
+ if (check_format (false) == FAILURE)
return MATCH_ERROR;
if (gfc_match_eos () != MATCH_YES)
gfc_statement_label->format = e;
mode = MODE_COPY;
- check_format (); /* Guaranteed to succeed */
+ check_format (false); /* Guaranteed to succeed */
gfc_match_eos (); /* Guaranteed to succeed */
return MATCH_YES;
expr = dt->format_expr;
if (expr != NULL && expr->expr_type == EXPR_CONSTANT)
- check_format_string (expr);
+ check_format_string (expr, k == M_READ);
return m;
}