5.8 Goto Statements
[A
goto_statement
specifies an explicit transfer of control from this
statement
to a target statement with a given label.]
Syntax
goto_statement ::= goto label_name;
Name Resolution Rules
{target statement
(of a goto_statement)} The
label_name
shall resolve to denote a
label;
the
statement
with that
label
is the
target statement.
Legality Rules
It follows from the second rule that if the
target
statement
is enclosed by such a construct, then the
goto_statement
cannot be outside.
Dynamic Semantics
{execution (goto_statement)
[partial]} The execution of a
goto_statement
transfers control to the target statement, completing the execution of
any
compound_statement
that encloses the
goto_statement
but does not enclose the target.
Examples
Example of a loop
containing a goto statement:
<<Sort>>
for I in 1 .. N-1 loop
if A(I) > A(I+1) then
Exchange(A(I), A(I+1));
goto Sort;
end if;
end loop;