------- Comment #9 from steven at gcc dot gnu dot org 2006-01-08 21:45 -------
Actually we already know for sure that the label exists and that it is a valid
jump target. From resolve_branch:
/* Step one: is this a valid branching target? */
if (lp->defined == ST_LABEL_UNKNOWN)
{
gfc_error ("Label %d referenced at %L is never defined", lp->value,
&lp->where);
return;
}
if (lp->defined != ST_LABEL_TARGET)
{
gfc_error ("Statement at %L is not a valid branch target statement "
"for the branch statement at %L", &lp->where, &code->loc);
return;
}
/* Step two: make sure this branch is not a branch to itself ;-) */
if (code->here == label)
{
gfc_warning ("Branch at %L causes an infinite loop", &code->loc);
return;
}
/* Step three: Try to find the label in the parse tree. To do this,
we traverse the tree block-by-block: first the block that
contains this GOTO, then the block that it is nested in, etc. We
can ignore other blocks because branching into another block is
not allowed. */
Step three is what we can skip if we want to allow this kind of invalid jumping
around through a program unit.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18540