pTAL Reference Manual (H06.08+)

Statements
HP pTAL Reference Manual523746-006
12-25
GOTO and Target Statements With Different
Trapping States
If a GOTO statement and the target statement are in different BEGIN-END blocks:
You must declare the target label in a LABEL declaration in the containing
procedure.
Overflow trapping must be enabled in both blocks or disabled in both blocks. The
respective overflow trapping states can be established by compiler directive, by
procedure attribute, or by BEGIN-END block attribute.
A GOTO statement in a BEGIN-END block that does not specify a block-level
trapping attribute cannot branch to a label in a BEGIN-END block in which a block-
level trapping attribute is specified.
The compiler uses attributes on BEGIN-END blocks to determines whether a GOTO
within one BEGIN-END block can branch to a label in another BEGIN-END block.
For more information, see Section 13, Hardware Indicators.
Note. LABEL is an invalid data type for a formal parameter. You cannot pass a label as an
actual parameter.
Example 12-24. Nonlocal GOTO and Target Statements That Have Different
Trapping States
PROC p OVERFLOW_TRAPS;
BEGIN
INT i := 0;
label_a: ! Overflow traps are enabled at label_a
i := i + 1;
IF i < 10 THEN
GOTO label_a ! OK: Traps enabled here and at label_a
ELSE
BEGIN:ENABLE_OVERFLOW_TRAPS
GOTO label_a; ! OK: Branch from block with traps
IF i <> 1 THEN ! specified
BEGIN
label_b: ...
END;
END;
BEGIN:DISABLE_OVERFLOW_TRAPS
GOTO label_b; ! ERROR: Cannot branch between blocks
END; ! that have different trapping states
BEGIN
GOTO label_b; ! ERROR: Cannot branch from a BEGIN-END
END; ! block that does not specify a trapping
END; ! attribute to a BEGIN-END block that
! does