J.15.7 Pragmas Interrupt_Handler and Attach_Handler
Name Resolution Rules
For the Interrupt_Handler and Attach_Handler pragmas,
shall resolve to denote a protected procedure with a parameterless profile.
For the Attach_Handler pragma, the expected type
for the expression is Interrupts.Interrupt_Id (see C.3.2).
The Attach_Handler and Interrupt_Handler pragmas
are only allowed immediately within the protected_definition
where the corresponding subprogram is declared. The corresponding protected_type_declaration
shall be a library-level declaration, and shall not be declared within
a generic body. In addition to the places where Legality
Rules normally apply (see 12.3), these rules
also apply in the private part of an instance of a generic unit.
We cannot allow these pragmas in a generic body,
because legality rules are not checked for instance bodies, and these
should not be allowed if the instance is not at the library level. The
protected types can be declared in the private part if this is desired.
Note that while the 'Access to use the handler would provide the check
in the case of Interrupt_Handler, there is no other check for Attach_Handler.
Since these pragmas are so similar, we want the rules to be the same.
For an implementation that supports Annex C, a
pragma Interrupt_Handler specifies the Interrupt_Handler aspect (see
C.3.1) for the protected procedure handler_name
to have the value True. For an implementation that supports Annex C,
a pragma Attach_Handler specifies the Attach_Handler aspect (see C.3.1)
for the protected procedure handler_name
to have the value of the given expression[
as evaluated at object creation time].
Incompatibilities With Ada 2005
Correction: Added missing
generic contract wording for the pragma Attach_Handler and Interrupt_Handler.
This means that nested instances with these pragmas in the private part
are now illegal. This is not likely to occur in practice.
Wording Changes from Ada 2005
This subclause is new. Pragmas Interrupt_Handler
and Attach_Handler were moved here from C.3.1;
aspects Interrupt_Handler and Attach_Handler live there now.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe