Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
Annotated Ada Reference Manual (Ada 2022)Legal Information
Contents   Index   References   Search   Previous   Next 

J.15.7 Pragmas Interrupt_Handler and Attach_Handler


{AI05-0229-1} The form of a pragma Interrupt_Handler is as follows: 
  pragma Interrupt_Handler (handler_name);
{AI05-0229-1} The form of a pragma Attach_Handler is as follows: 
  pragma Attach_Handler (handler_name, expression);

Name Resolution Rules

{AI05-0229-1} For the Interrupt_Handler and Attach_Handler pragmas, the handler_name shall resolve to denote a protected procedure with a parameterless profile.
{AI05-0229-1} For the Attach_Handler pragma, the expected type for the expression is Interrupts.Interrupt_Id (see C.3.2).

Legality Rules

{AI05-0033-1} {AI05-0229-1} 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 or single_protected_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. 
Discussion: In the case of a protected_type_declaration, an object_declaration of an object of that type need not be at library level.
{AI05-0033-1} 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. 

Static Semantics

{AI05-0229-1} 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

{AI05-0033-1} 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

{AI05-0229-1} {AI05-0299-1} 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. 

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe