This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/18540] Jumping into blocks gives error rather than warning
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jan 2006 21:45:44 -0000
- Subject: [Bug fortran/18540] Jumping into blocks gives error rather than warning
- References: <bug-18540-9236@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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