10.1.5 Pragmas and Program Units
1
[This subclause discusses pragmas related to program
units, library units, and compilations.]
Name Resolution Rules
2
{program unit pragma
[distributed]} {pragma,
program unit [distributed]} Certain
pragmas
are defined to be
program unit pragmas.
{apply
(to a program unit by a program unit pragma) [partial]} 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
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
A program unit pragma
shall appear in one of these places:
4
- 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
Ramification: The name
has to denote the immediately preceding library_unit_declaration.
5/1
- {8652/0033}
{AI95-00136-01}
Immediately within the visible part declaration
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
Ramification: The argument is optional
in this case.
6
- 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
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
{library unit pragma
[distributed]} {pragma,
library unit [distributed]} {program
unit pragma (library unit pragmas) [partial]} {pragma,
program unit (library unit pragmas) [partial]} Certain
program unit pragmas are defined to be
library unit pragmas. The
name, if any, in a library unit pragma shall
denote the declaration of a library unit.
7.a
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
7.1/1
{
8652/0034}
{
AI95-00041-01}
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.
Post-Compilation Rules
8
{configuration pragma
[distributed]} {pragma,
configuration [distributed]} Certain
pragmas
are defined to be
configuration pragmas; they shall appear before
the first
compilation_unit of a
compilation.
[They are generally used to select a partition-wide or system-wide option.]
The
pragma applies to all
compilation_units
appearing in the
compilation, unless there
are none, in which case it applies to all future
compilation_units
compiled into the same environment.
Implementation Permissions
9/2
{
AI95-00212-01}
An implementation may
require that configuration
pragmas that select partition-wide or system-wide options be compiled place
restrictions on configuration pragmas, so long as it allows them
when the environment contains no
library_items
other than those of the predefined environment.
In
this case, the implementation shall still accept configuration pragmas
in individual compilations that confirm the initially selected partition-wide
or system-wide options.
Implementation Advice
10/1
{
8652/0034}
{
AI95-00041-01}
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.
10.a/2
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 95
10.b/2
{
8652/0033}
{
AI95-00136-01}
Corrigendum: The wording was corrected to
ensure that a program unit pragma cannot appear in private parts or generic
formal parts.
10.c/2
{
8652/0034}
{
AI95-00041-01}
Corrigendum: The wording was clarified to
explain the meaning of program unit and library unit pragmas in generic
units.
10.d/2
The Implementation Advice
added by the Corrigendum was moved, as it was not in the normal order.
(This changes the paragraph number.) It originally was directly after
the new Static Semantics rule.
10.e/2
{
AI95-00212-01}
The permission to place restrictions was clarified
to:
10.f/2
- Ensure
that it applies only to partition-wide configuration pragmas, not ones
like Assertion_Policy (see 11.4.2), which
can be different in different units; and
10.g/2
- Ensure
that confirming pragmas are always allowed.