Commit e444a887 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/32483 (edit descriptor checking: Compile-time check for zero width for reading)

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-29  Tobias Burnus  <burnus@net-b.de>

	PR fortran/32483
	* gfortran.dg/fmt_read_2.f90: New.

From-SVN: r126107
parent d7505f46
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> 2007-06-28 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR other/31400 PR other/31400
......
...@@ -257,10 +257,12 @@ format_lex (void) ...@@ -257,10 +257,12 @@ format_lex (void)
do do
{ {
c = next_char_not_space (); c = next_char_not_space ();
if (c != '0')
zflag = 0;
if (ISDIGIT (c)) if (ISDIGIT (c))
value = 10 * value + c - '0'; {
value = 10 * value + c - '0';
if (c != '0')
zflag = 0;
}
} }
while (ISDIGIT (c)); while (ISDIGIT (c));
...@@ -429,7 +431,7 @@ format_lex (void) ...@@ -429,7 +431,7 @@ format_lex (void)
means that the warning message is a little less than great. */ means that the warning message is a little less than great. */
static try static try
check_format (void) check_format (bool is_input)
{ {
const char *posint_required = _("Positive width required"); const char *posint_required = _("Positive width required");
const char *nonneg_required = _("Nonnegative width required"); const char *nonneg_required = _("Nonnegative width required");
...@@ -670,6 +672,11 @@ data_desc: ...@@ -670,6 +672,11 @@ data_desc:
error = nonneg_required; error = nonneg_required;
goto syntax; goto syntax;
} }
else if (is_input && t == FMT_ZERO)
{
error = posint_required;
goto syntax;
}
t = format_lex (); t = format_lex ();
if (t != FMT_PERIOD) if (t != FMT_PERIOD)
...@@ -719,6 +726,11 @@ data_desc: ...@@ -719,6 +726,11 @@ data_desc:
error = nonneg_required; error = nonneg_required;
goto syntax; goto syntax;
} }
else if (is_input && t == FMT_ZERO)
{
error = posint_required;
goto syntax;
}
t = format_lex (); t = format_lex ();
if (t != FMT_PERIOD) if (t != FMT_PERIOD)
...@@ -854,11 +866,11 @@ finished: ...@@ -854,11 +866,11 @@ finished:
like a format string. */ like a format string. */
static void static void
check_format_string (gfc_expr *e) check_format_string (gfc_expr *e, bool is_input)
{ {
mode = MODE_STRING; mode = MODE_STRING;
format_string = e->value.character.string; format_string = e->value.character.string;
check_format (); check_format (is_input);
} }
...@@ -893,7 +905,7 @@ gfc_match_format (void) ...@@ -893,7 +905,7 @@ gfc_match_format (void)
start = gfc_current_locus; start = gfc_current_locus;
if (check_format () == FAILURE) if (check_format (false) == FAILURE)
return MATCH_ERROR; return MATCH_ERROR;
if (gfc_match_eos () != MATCH_YES) if (gfc_match_eos () != MATCH_YES)
...@@ -920,7 +932,7 @@ gfc_match_format (void) ...@@ -920,7 +932,7 @@ gfc_match_format (void)
gfc_statement_label->format = e; gfc_statement_label->format = e;
mode = MODE_COPY; mode = MODE_COPY;
check_format (); /* Guaranteed to succeed */ check_format (false); /* Guaranteed to succeed */
gfc_match_eos (); /* Guaranteed to succeed */ gfc_match_eos (); /* Guaranteed to succeed */
return MATCH_YES; return MATCH_YES;
...@@ -2740,7 +2752,7 @@ if (condition) \ ...@@ -2740,7 +2752,7 @@ if (condition) \
expr = dt->format_expr; expr = dt->format_expr;
if (expr != NULL && expr->expr_type == EXPR_CONSTANT) if (expr != NULL && expr->expr_type == EXPR_CONSTANT)
check_format_string (expr); check_format_string (expr, k == M_READ);
return m; return m;
} }
......
2007-06-29 Tobias Burnus <burnus@net-b.de>
PR fortran/32483
* gfortran.dg/fmt_read_2.f90: New.
2007-06-28 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2007-06-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* gfortran.dg/open_errors.f90: Check for existance of temptestfile. * gfortran.dg/open_errors.f90: Check for existance of temptestfile.
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