13.12 Pragma Restrictions and Pragma Profile
This Reference Manual output has not been verified, and may contain omissions or errors. Report any problems on the tracking issue
[A pragma
Restrictions expresses the user's intent to abide by certain restrictions. A pragma
Profile expresses the user's intent to abide by a set of Restrictions or other specified run-time policies. These may facilitate the construction of simpler run-time environments.]
Syntax
2The form of a pragma
Restrictions is as follows:
pragma Restrictions(restriction
{, restriction
});
restriction
::=
restriction_identifier
| restriction_parameter_identifier
=> restriction_parameter_argument
4.1/2
restriction_parameter_argument
::=
name
| expression
Name Resolution Rules
5Unless otherwise specified for a particular restriction, the expression
is expected to be of any integer type.
Legality Rules
6Unless otherwise specified for a particular restriction, the expression
shall be static, and its value shall be nonnegative.
Paragraph 7 was deleted.
Post-Compilation Rules
8/3A pragma
Restrictions is a configuration pragma. If a pragma
Restrictions applies to any compilation unit included in the partition, this may impose either (or both) of two kinds of requirements, as specified for the particular restriction:
- A restriction may impose requirements on some or all of the units comprising the partition. Unless otherwise specified for a particular restriction, such a requirement applies to all of the units comprising the partition and is enforced via a post-compilation check.
- A restriction may impose requirements on the run-time behavior of the program, as indicated by the specification of run-time behavior associated with a violation of the requirement.
In this latter case, there is no post-compilation check needed for the requirement.
{8652/0042} For the purpose of checking whether a partition contains constructs that violate any restriction (unless specified otherwise for a particular restriction):
- {8652/0042} Generic instances are logically expanded at the point of instantiation;
- {8652/0042} If an object of a type is declared or allocated and not explicitly initialized, then all expressions appearing in the definition for the type and any of its ancestors are presumed to be used;
- {8652/0042} A
default_expression
for a formal parameter or a generic formal object is considered to be used if and only if the corresponding actual parameter is not provided in a given call or instantiation.
Implementation Permissions
8.7/3An implementation may provide implementation-defined restrictions; the identifier for an implementation-defined restriction shall differ from those of the language-defined restrictions.
An implementation may place limitations on the values of the expression
that are supported, and limitations on the supported combinations of restrictions. The consequences of violating such limitations are implementation defined.
Such limitations may be enforced at compile time or at run time. Alternatively, the implementation is allowed to declare violations of the restrictions to be erroneous, and not enforce them at all.
{8652/0042} An implementation is permitted to omit restriction checks for code that is recognized at compile time to be unreachable and for which no code is generated.
{8652/0043} Whenever enforcement of a restriction is not required prior to execution, an implementation may nevertheless enforce the restriction prior to execution of a partition to which the restriction applies, provided that every execution of the partition would violate the restriction.
Syntax
10/3The form of a pragma
Profile is as follows:
pragma Profile (profile_identifier
{, profile_pragma_argument_association
});
Legality Rules
12/3The profile_identifier
shall be the name of a usage profile. The semantics of any profile_pragma_argument_association
s are defined by the usage profile specified by the profile_identifier
.
Static Semantics
13/3A profile is equivalent to the set of configuration pragmas that is defined for each usage profile.
Post-Compilation Rules
14/3A pragma
Profile is a configuration pragma. There may be more than one pragma
Profile for a partition.
Implementation Permissions
15/3An implementation may provide implementation-defined usage profiles; the identifier for an implementation-defined usage profile shall differ from those of the language-defined usage profiles.
NOTE 2 An implementation has to enforce the restrictions in cases where enforcement is required, even if it chooses not to take advantage of the restrictions in terms of efficiency.
It is not the intent that an implementation will support a different run-time system for every possible combination of restrictions. An implementation might support only two run-time systems, and document a set of restrictions that is sufficient to allow use of the more efficient and safe one.
Extensions to Ada 83
Pragma Restrictions is new to Ada 95.
Extensions to Ada 95
Pragma
Profile is new; it was moved here by Ada 2012 and renamed to a "usage profile" but was otherwise unchanged.
Wording Changes from Ada 95
{8652/0042} Corrigendum: Corrected the wording so that restrictions are checked inside of generic instantiations and in default expressions. Since not making these checks would violate the purpose of restrictions, we are not documenting this as an incompatibility.
{8652/0043} Corrigendum: Added a permission that restrictions can be enforced at compile-time. While this is technically incompatible, documenting it as such would be unnecessarily alarming - there should not be any programs depending on the runtime failure of restrictions.
The syntax of a restriction_parameter_argument
has been defined to better support restriction No_Dependence (see 13.12.1).
Wording Changes from Ada 2005
13.12.1 Language-Defined Restrictions and Profiles
Static Semantics
1/2The following restriction_identifier
s are language defined (additional restrictions are defined in the Specialized Needs Annexes):
No_Implementation_Aspect_Specifications
- There are no implementation-defined aspects specified by an
aspect_specification
. This restriction applies only to the current compilation or environment, not the entire partition.
This restriction (as well as others below) applies only to the current compilation, because it is likely that the runtime (and possibly user-written low-level code) will need to use implementation-defined aspects. But a partition-wide restriction applies everywhere, including the runtime.
No_Implementation_Attributes
- There are no implementation-defined attributes. This restriction applies only to the current compilation or environment, not the entire partition.
No_Implementation_Identifiers- There are no usage names that denote declarations with implementation-defined identifiers that occur within language-defined packages or instances of language-defined generic packages. Such identifiers can arise as follows:
- The following language-defined packages and generic packages allow implementation-defined identifiers:
- package System (see 13.7);
- package Standard (see A.1);
- package Ada.Command_Line (see A.15);
- package Interfaces.C (see B.3);
- package Interfaces.C.Strings (see B.3.1);
- package Interfaces.C.Pointers (see B.3.2);
- package Interfaces.COBOL (see B.4);
- package Interfaces.Fortran (see B.5);
- The following language-defined packages contain only implementation-defined identifiers:
- package System.Machine_Code (see 13.8);
- package Ada.Directories.Information (see A.16);
- nested Implementation packages of the Queue containers (see A.18.28-31);
- package Interfaces (see B.2);
- package Ada.Interrupts.Names (see C.3.2).
- For package Standard, Standard.Long_Integer and Standard.Long_Float are considered language-defined identifiers, but identifiers such as Standard.Short_Short_Integer are considered implementation-defined.
- This restriction applies only to the current compilation or environment, not the entire partition.
No_Implementation_Pragmas- There are no implementation-defined pragmas or pragma arguments. This restriction applies only to the current compilation or environment, not the entire partition.
No_Implementation_Units- There is no mention in the
context_clause
of any implementation-defined descendants of packages Ada, Interfaces, or System. This restriction applies only to the current compilation or environment, not the entire partition. 4/3
No_Obsolescent_Features- There is no use of language features defined in Annex J. It is implementation defined whether uses of the renamings of J.1 and of the
pragma
s of J.15 are detected by this restriction. This restriction applies only to the current compilation or environment, not the entire partition.
A user could compile a rename like
with Ada.Text_IO;
package Text_IO renames Ada.Text_IO;
Such a rename must not be disallowed by this restriction, nor should the compilation of such a rename be restricted by an implementation. Many implementations implement the renames of J.1 by compiling them normally; we do not want to require implementations to use a special mechanism to implement these renames.
The pragmas have the same functionality as the corresponding aspect (unlike the typical obsolescent feature), and rejecting them could be a significant portability problem for existing code.
The following restriction_parameter_identifier
s are language defined:
No_Dependence
- Specifies a library unit on which there are no semantic dependences.
No_Specification_of_Aspect- Identifies an aspect for which no
aspect_specification
,attribute_definition_clause
, orpragma
is given. 6.2/3
No_Use_Of_Attribute- Identifies an attribute for which no
attribute_reference
orattribute_definition_clause
is given. 6.3/3
No_Use_Of_Pragma- Identifies a
pragma
which is not to be used. 6.4/5
No_Unrecognized_Aspects- There are no
aspect_specification
s having an unrecognized aspect_identifier
. This restriction applies only to the current compilation or environment, not the entire partition.
When this restriction is in effect, unrecognized aspects cannot be ignored in the current compilation; they violate the restriction. This is true despite the Implementation Permissions of 13.1.1.
No_Unrecognized_Pragmas
- There are no
pragma
s having an unrecognized pragmaidentifier
. This restriction applies only to the current compilation or environment, not the entire partition.
When this restriction is in effect, unrecognized pragmas cannot be ignored in the current compilation; they violate the restriction. This is true despite the rules of 2.8.
Legality Rules
7/5The restriction_parameter_argument
of a No_Dependence restriction shall be a name
; the name
shall have the form of a full expanded name of a library unit, but can be a name that has no corresponding unit currently present in the environment.
The restriction_parameter_argument
of a No_Specification_of_Aspect restriction shall be an identifier
; this is an identifier specific to a pragma (see 2.8) and does not denote any declaration.
This restriction_parameter_argument
is not resolved as it is an identifier specific to a pragma. As for No_Dependence, there is no check that the aspect identifier
is meaningful; it might refer to an implementation-defined aspect on one implementation, but nothing at all on another implementation.
The restriction_parameter_argument
of a No_Use_Of_Attribute restriction shall be an identifier
or one of the reserved words Access, Delta, Digits, Mod, or Range; this is an identifier specific to a pragma.
This restriction_parameter_argument
is not resolved as it is an identifier specific to a pragma. There is no check that the attribute identifier refers to a known attribute_designator
; it might refer to an implementation-defined attribute on one implementation, but nothing at all on another implementation.
The restriction_parameter_argument
of a No_Use_Of_Pragma restriction shall be an identifier
or the reserved word Interface; this is an identifier specific to a pragma.
This restriction_parameter_argument
is not resolved as it is an identifier specific to a pragma. There is no check that the pragma identifier refers to a known pragma
; it might refer to an implementation-defined pragma on one implementation, but nothing at all on another implementation.
Post-Compilation Rules
8/3No compilation unit included in the partition shall depend semantically on the library unit identified by the name
of a No_Dependence restriction.
There is no requirement that the library unit actually exists. One possible use of the pragma is to prevent the use of implementation-defined units; when the program is ported to a different compiler, it is perfectly reasonable that no unit with the name exists.
Static Semantics
9/3The following profile_identifier
is language defined:
No_Implementation_Extensions
For usage profile No_Implementation_Extensions, there shall be no profile_pragma_argument_association
s.
The No_Implementation_Extensions usage profile is equivalent to the following restrictions:
No_Implementation_Aspect_Specifications,
No_Implementation_Attributes,
No_Implementation_Identifiers,
No_Implementation_Pragmas,
No_Implementation_Units.
Extensions to Ada 95
Restrictions No_Implementation_Attributes, No_Implementation_Pragmas, and No_Obsolescent_Features are new.
Extensions to Ada 2005
Restrictions No_Implementation_Aspect_Specifications, No_Implementation_Identifiers, No_Implementation_Units, No_Specification_of_Aspect, No_Use_of_Attribute, and No_Use_of_Pragma are new.