Commit 90ba4622 authored by fxcoudert's avatar fxcoudert
Browse files

PR fortran/25106

	* parse.c (next_free): Use new prototype for gfc_match_st_label.
	Correctly emit hard error if a label is zero.
	* match.c (gfc_match_st_label): Never allow zero as a valid
	label.
	(gfc_match, gfc_match_do, gfc_match_goto): Use new prototype for
	gfc_match_st_label.
	* primary.c (): Use new prototype for gfc_match_st_label.
	* io.c (): Likewise.
	* match.h: Likewise.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107999 138bc75d-0d04-0410-961f-82ee72b054a4
parent c59487b8
2005-12-30 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/25106
* parse.c (next_free): Use new prototype for gfc_match_st_label.
Correctly emit hard error if a label is zero.
* match.c (gfc_match_st_label): Never allow zero as a valid
label.
(gfc_match, gfc_match_do, gfc_match_goto): Use new prototype for
gfc_match_st_label.
* primary.c (): Use new prototype for gfc_match_st_label.
* io.c (): Likewise.
* match.h: Likewise.
2005-12-02 Richard Guenther <rguenther@suse.de> 2005-12-02 Richard Guenther <rguenther@suse.de>
* trans.h (build1_v): Use build1, not build to build the * trans.h (build1_v): Use build1, not build to build the
......
...@@ -1591,7 +1591,7 @@ match_dt_format (gfc_dt * dt) ...@@ -1591,7 +1591,7 @@ match_dt_format (gfc_dt * dt)
return MATCH_YES; return MATCH_YES;
} }
if (gfc_match_st_label (&label, 0) == MATCH_YES) if (gfc_match_st_label (&label) == MATCH_YES)
{ {
if (dt->format_expr != NULL || dt->format_label != NULL) if (dt->format_expr != NULL || dt->format_label != NULL)
{ {
......
...@@ -217,7 +217,7 @@ gfc_match_small_int (int *value) ...@@ -217,7 +217,7 @@ gfc_match_small_int (int *value)
do most of the work. */ do most of the work. */
match match
gfc_match_st_label (gfc_st_label ** label, int allow_zero) gfc_match_st_label (gfc_st_label ** label)
{ {
locus old_loc; locus old_loc;
match m; match m;
...@@ -229,13 +229,16 @@ gfc_match_st_label (gfc_st_label ** label, int allow_zero) ...@@ -229,13 +229,16 @@ gfc_match_st_label (gfc_st_label ** label, int allow_zero)
if (m != MATCH_YES) if (m != MATCH_YES)
return m; return m;
if (((i == 0) && allow_zero) || i <= 99999) if (i > 0 && i <= 99999)
{ {
*label = gfc_get_st_label (i); *label = gfc_get_st_label (i);
return MATCH_YES; return MATCH_YES;
} }
gfc_error ("Statement label at %C is out of range"); if (i == 0)
gfc_error ("Statement label at %C is zero");
else
gfc_error ("Statement label at %C is out of range");
gfc_current_locus = old_loc; gfc_current_locus = old_loc;
return MATCH_ERROR; return MATCH_ERROR;
} }
...@@ -690,7 +693,7 @@ loop: ...@@ -690,7 +693,7 @@ loop:
case 'l': case 'l':
label = va_arg (argp, gfc_st_label **); label = va_arg (argp, gfc_st_label **);
n = gfc_match_st_label (label, 0); n = gfc_match_st_label (label);
if (n != MATCH_YES) if (n != MATCH_YES)
{ {
m = n; m = n;
...@@ -1242,7 +1245,7 @@ gfc_match_do (void) ...@@ -1242,7 +1245,7 @@ gfc_match_do (void)
if (gfc_match (" do") != MATCH_YES) if (gfc_match (" do") != MATCH_YES)
return MATCH_NO; return MATCH_NO;
m = gfc_match_st_label (&label, 0); m = gfc_match_st_label (&label);
if (m == MATCH_ERROR) if (m == MATCH_ERROR)
goto cleanup; goto cleanup;
...@@ -1275,7 +1278,7 @@ gfc_match_do (void) ...@@ -1275,7 +1278,7 @@ gfc_match_do (void)
gfc_match_label (); /* This won't error */ gfc_match_label (); /* This won't error */
gfc_match (" do "); /* This will work */ gfc_match (" do "); /* This will work */
gfc_match_st_label (&label, 0); /* Can't error out */ gfc_match_st_label (&label); /* Can't error out */
gfc_match_char (','); /* Optional comma */ gfc_match_char (','); /* Optional comma */
m = gfc_match_iterator (&iter, 0); m = gfc_match_iterator (&iter, 0);
...@@ -1585,7 +1588,7 @@ gfc_match_goto (void) ...@@ -1585,7 +1588,7 @@ gfc_match_goto (void)
do do
{ {
m = gfc_match_st_label (&label, 0); m = gfc_match_st_label (&label);
if (m != MATCH_YES) if (m != MATCH_YES)
goto syntax; goto syntax;
...@@ -1631,7 +1634,7 @@ gfc_match_goto (void) ...@@ -1631,7 +1634,7 @@ gfc_match_goto (void)
do do
{ {
m = gfc_match_st_label (&label, 0); m = gfc_match_st_label (&label);
if (m != MATCH_YES) if (m != MATCH_YES)
goto syntax; goto syntax;
......
...@@ -41,7 +41,7 @@ extern gfc_st_label *gfc_statement_label; ...@@ -41,7 +41,7 @@ extern gfc_st_label *gfc_statement_label;
match gfc_match_space (void); match gfc_match_space (void);
match gfc_match_eos (void); match gfc_match_eos (void);
match gfc_match_small_literal_int (int *); match gfc_match_small_literal_int (int *);
match gfc_match_st_label (gfc_st_label **, int); match gfc_match_st_label (gfc_st_label **);
match gfc_match_label (void); match gfc_match_label (void);
match gfc_match_small_int (int *); match gfc_match_small_int (int *);
int gfc_match_strings (mstring *); int gfc_match_strings (mstring *);
......
...@@ -318,30 +318,25 @@ next_free (void) ...@@ -318,30 +318,25 @@ next_free (void)
if (ISDIGIT (c)) if (ISDIGIT (c))
{ {
/* Found a statement label? */ /* Found a statement label? */
m = gfc_match_st_label (&gfc_statement_label, 0); m = gfc_match_st_label (&gfc_statement_label);
d = gfc_peek_char (); d = gfc_peek_char ();
if (m != MATCH_YES || !gfc_is_whitespace (d)) if (m != MATCH_YES || !gfc_is_whitespace (d))
{ {
gfc_match_small_literal_int (&c);
if (c == 0)
gfc_error_now ("Statement label at %C is zero");
else
gfc_error_now ("Statement label at %C is out of range");
do do
{ c = gfc_next_char ();
/* Skip the bad statement label. */ while (ISDIGIT(c));
gfc_warning_now ("Ignoring bad statement label at %C");
c = gfc_next_char ();
}
while (ISDIGIT (c));
} }
else else
{ {
label_locus = gfc_current_locus; label_locus = gfc_current_locus;
if (gfc_statement_label->value == 0)
{
gfc_warning_now ("Ignoring statement label of zero at %C");
gfc_free_st_label (gfc_statement_label);
gfc_statement_label = NULL;
}
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
if (gfc_match_eos () == MATCH_YES) if (gfc_match_eos () == MATCH_YES)
......
...@@ -1474,7 +1474,7 @@ gfc_match_actual_arglist (int sub_flag, gfc_actual_arglist ** argp) ...@@ -1474,7 +1474,7 @@ gfc_match_actual_arglist (int sub_flag, gfc_actual_arglist ** argp)
if (sub_flag && gfc_match_char ('*') == MATCH_YES) if (sub_flag && gfc_match_char ('*') == MATCH_YES)
{ {
m = gfc_match_st_label (&label, 0); m = gfc_match_st_label (&label);
if (m == MATCH_NO) if (m == MATCH_NO)
gfc_error ("Expected alternate return label at %C"); gfc_error ("Expected alternate return label at %C");
if (m != MATCH_YES) if (m != MATCH_YES)
......
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