Annotated Ada Reference Manual (Ada 202y Draft 1)Legal Information
Contents   Index   References   Search   Previous   Next 

J.15 Aspect-related Pragmas

1/3
{AI05-0229-1} Pragmas can be used as an alternative to aspect_specifications to specify certain aspects. 

Name Resolution Rules

2/5
{AI12-0417-1} Certain pragmas are defined to be program unit pragmas. A name given as the argument of a program unit pragma shall resolve to denote the declarations or renamings of one or more program units that occur immediately within the declarative region or compilation in which the pragma immediately occurs, or it shall resolve to denote the declaration of the immediately enclosing program unit (if any); the pragma applies to the denoted program unit(s). If there are no names given as arguments, the pragma applies to the immediately enclosing program unit. 
2.a/5
Ramification: The fact that this is a Name Resolution Rule means that the pragma will not apply to declarations from outer declarative regions. 

Legality Rules

3/5
{AI12-0417-1} A program unit pragma shall appear in one of these places: 
4/5
{AI12-0417-1} At the place of a compilation_unit, in which case the pragma shall immediately follow in the same compilation (except for other pragmas) a library_unit_declaration that is a subprogram_declaration, generic_subprogram_declaration, or generic_instantiation, and the pragma shall have an argument that is a name denoting that declaration. 
4.a/5
Ramification: The name has to denote the immediately preceding library_unit_declaration.
5/5
{8652/0033} {AI95-00136-01} {AI12-0417-1} Immediately within the visible part of a program unit and before any nested declaration (but not within a generic formal part), in which case the argument, if any, shall be a direct_name that denotes the immediately enclosing program unit declaration. 
5.a/5
Ramification: The argument is optional in this case. 
6/5
{AI12-0417-1} At the place of a declaration other than the first, of a declarative_part or program unit declaration, in which case the pragma shall have an argument, which shall be a direct_name that denotes one or more of the following (and nothing else): a subprogram_declaration, a generic_subprogram_declaration, or a generic_instantiation, of the same declarative_part or program unit declaration. 
6.a/5
Ramification: If you want to denote a subprogram_body that is not a completion, or a package_declaration, for example, you have to put the pragma inside. 
7/5
{AI05-0132-1} {AI12-0417-1} Certain program unit pragmas are defined to be library unit pragmas. If a library unit pragma applies to a program unit, the program unit shall be a library unit. 
7.a/5
Ramification: This, together with the rules for program unit pragmas above, implies that if a library unit pragma applies to a subprogram_declaration (and similar things), it has to appear immediately after the compilation_unit, whereas if the pragma applies to a package_declaration, a subprogram_body that is not a completion (and similar things), it has to appear inside, as the first declarative_item.

Static Semantics

8/5
{8652/0034} {AI95-00041-01} {AI12-0417-1} A library unit pragma that applies to a generic unit does not apply to its instances, unless a specific rule for the pragma specifies the contrary.

Implementation Advice

9/5
{8652/0034} {AI95-00041-01} {AI12-0417-1} When applied to a generic unit, a program unit pragma that is not a library unit pragma should apply to each instance of the generic unit for which there is not an overriding pragma applied directly to the instance. 
9.a/5
Implementation Advice: When applied to a generic unit, a program unit pragma that is not a library unit pragma should apply to each instance of the generic unit for which there is not an overriding pragma applied directly to the instance.

Wording Changes from Ada 2005

9.b/3
{AI05-0229-1} {AI05-0299-1} This subclause is new. Many existing pragmas have been converted into aspects; the pragmas have moved here.
9.c/5
{AI05-0132-1} {AI12-0417-1} Correction: A library unit pragma must apply directly to a library unit, even if no name is given in the pragma. 

Wording Changes from Ada 2012

9.d/5
{AI12-0417-1} The terms “program unit pragma” and “library unit pragma” were moved here as all of the pragmas that use these terms are now in this annex. 

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