Skip to main content

13.12 Pragma Restrictions and Pragma Profile

danger

This Reference Manual output has not been verified, and may contain omissions or errors. Report any problems on the tracking issue

1/3

[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

2

The form of a pragma Restrictions is as follows:

3

pragma Restrictions(restriction{, restriction});

4/2

restriction ::= restriction_identifier
| restriction_parameter_identifier => restriction_parameter_argument

4.1/2

restriction_parameter_argument ::= name | expression

Name Resolution Rules

5

Unless otherwise specified for a particular restriction, the expression is expected to be of any integer type.

Legality Rules

6

Unless otherwise specified for a particular restriction, the expression shall be static, and its value shall be nonnegative.

7.a/3
This paragraph was deleted.

Paragraph 7 was deleted.

Post-Compilation Rules

8/3

A 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:

8.1/3
  • 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.
  • 8.2/3
  • 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.
8.a.1/3
ramification

In this latter case, there is no post-compilation check needed for the requirement.

8.3/1

{8652/0042} For the purpose of checking whether a partition contains constructs that violate any restriction (unless specified otherwise for a particular restriction):

8.4/1
  • {8652/0042} Generic instances are logically expanded at the point of instantiation;
  • 8.5/1
  • {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;
  • 8.6/1
  • {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/3

An implementation may provide implementation-defined restrictions; the identifier for an implementation-defined restriction shall differ from those of the language-defined restrictions.

8.a.2/3
implementation defined

Implementation-defined restrictions allowed in a pragma Restrictions.

9

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.

9.a
implementation defined

The consequences of violating limitations on Restrictions pragmas.

9.b
ramification

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.

9.1/1

{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.

9.2/1

{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/3

The form of a pragma Profile is as follows:

11/3

pragma Profile (profile_identifier {, profile_pragma_argument_association});

Legality Rules

12/3

The profile_identifier shall be the name of a usage profile. The semantics of any profile_pragma_argument_associations are defined by the usage profile specified by the profile_identifier.

Static Semantics

13/3

A profile is equivalent to the set of configuration pragmas that is defined for each usage profile.

Post-Compilation Rules

14/3

A pragma Profile is a configuration pragma. There may be more than one pragma Profile for a partition.

Implementation Permissions

15/3

An 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.

15.a.1/3
implementation defined

Implementation-defined usage profiles allowed in a pragma Profile.

16/2

NOTE 1 Restrictions intended to facilitate the construction of efficient tasking run-time systems are defined in D.7. Restrictions intended for use when constructing high integrity systems are defined in H.4.

17

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.

17.a
discussion

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

17.b

Pragma Restrictions is new to Ada 95.

Extensions to Ada 95

17.c/3

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

17.d/2

{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.

17.e/2

{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.

17.f/2

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

17.g/3

Correction: When restrictions are checked has been clarified.

13.12.1 Language-Defined Restrictions and Profiles

Static Semantics

1/2

The following restriction_identifiers are language defined (additional restrictions are defined in the Specialized Needs Annexes):

1.1/3

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.
1.a/3
discussion

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.

2/2

No_Implementation_Attributes
There are no implementation-defined attributes. This restriction applies only to the current compilation or environment, not the entire partition.
2.1/3

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:
2.2/3
  • The following language-defined packages and generic packages allow implementation-defined identifiers:
2.3/3 2.11/3
  • The following language-defined packages contain only implementation-defined identifiers:
2.12/3
  • package System.Machine_Code (see 13.8);
  • 2.13/3
  • package Ada.Directories.Information (see A.16);
  • 2.14/3
  • nested Implementation packages of the Queue containers (see A.18.28-31);
  • 2.15/3
  • package Interfaces (see B.2);
  • 2.16/3
  • package Ada.Interrupts.Names (see C.3.2).
2.17/3
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.
2.18/3
This restriction applies only to the current compilation or environment, not the entire partition.
3/2

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.
3.1/3

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 pragmas of J.15 are detected by this restriction. This restriction applies only to the current compilation or environment, not the entire partition.
4.a/2
reason

A user could compile a rename like

4.b/2

with Ada.Text_IO; package Text_IO renames Ada.Text_IO;

4.c/2

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.

4.d/3

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.

5/3

The following restriction_parameter_identifiers are language defined:

6/2

No_Dependence
Specifies a library unit on which there are no semantic dependences.
6.1/3

No_Specification_of_Aspect
Identifies an aspect for which no aspect_specification, attribute_definition_clause, or pragma is given.
6.2/3

No_Use_Of_Attribute
Identifies an attribute for which no attribute_reference or attribute_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_specifications having an unrecognized aspect_identifier. This restriction applies only to the current compilation or environment, not the entire partition.
6.a/5
ramification

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.

6.5/5

No_Unrecognized_Pragmas
There are no pragmas having an unrecognized pragma identifier. This restriction applies only to the current compilation or environment, not the entire partition.
6.b/5
ramification

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/5

The 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.

7.a/2
ramification

This name is not resolved.

7.1/3

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.

7.b/3
ramification

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.

7.2/3

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.

7.c/3
ramification

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.

7.3/3

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.

7.d/3
ramification

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/3

No compilation unit included in the partition shall depend semantically on the library unit identified by the name of a No_Dependence restriction.

8.a/5
ramification

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/3

The following profile_identifier is language defined:

10/3

No_Implementation_Extensions

11/3

For usage profile No_Implementation_Extensions, there shall be no profile_pragma_argument_associations.

12/3

The No_Implementation_Extensions usage profile is equivalent to the following restrictions:

13/3

No_Implementation_Aspect_Specifications, No_Implementation_Attributes, No_Implementation_Identifiers, No_Implementation_Pragmas, No_Implementation_Units.

Extensions to Ada 95

13.a/2

Restrictions No_Implementation_Attributes, No_Implementation_Pragmas, and No_Obsolescent_Features are new.

13.b/2

Restriction No_Dependence is new.

Extensions to Ada 2005

13.c/3

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.

13.d/3

Profile No_Implementation_Extensions is new.

Extensions to Ada 2012

13.e/5

Restrictions No_Unrecognized_Aspects and No_Unrecognized_Pragmas are new.