13.1 Operational and Representation Aspects
This Reference Manual output has not been verified, and may contain omissions or errors. Report any problems on the tracking issue
{8652/0009} [Two kinds of aspects of entities can be specified: representation aspects and operational aspects. Representation aspects affect how the types and other entities of the language are to be mapped onto the underlying machine. Operational aspects determine other properties of entities.]
[Either kind of aspect of an entity may be specified by means of an aspect_specification
(see 13.1.1), which is an optional element of most kinds of declarations and applies to the entity or entities being declared. Aspects may also be specified by certain other constructs occurring subsequent to the declaration of the affected entity: a representation aspect value may be specified by means of a representation item and an operational aspect value may be specified by means of an operational item.]
{8652/0009} There are six kinds of representation items: attribute_definition_clause
s for representation attributes, enumeration_representation_clause
s, record_representation_clause
s, at_clause
s, component_clause
s, and representation pragmas. [ They can be provided to give more efficient representation or to interface with features that are outside the domain of the language (for example, peripheral hardware). ]
{8652/0009} An operational item is an attribute_definition_clause
for an operational attribute.
{8652/0009} [An operational item or a representation item applies to an entity identified by a local_name
, which denotes an entity declared local to the current declarative region, or a library unit declared immediately preceding a representation pragma in a compilation
.]
Language Design Principles
aspect_specification
on the declaration of the entity. Some aspects may be queried via attributes.Syntax
4/1{8652/0009} aspect_clause
::=
attribute_definition_clause
| enumeration_representation_clause
| record_representation_clause
| at_clause
5local_name
::=
direct_name
| direct_name
'attribute_designator
| library_unit_name
6/1{8652/0009} A representation pragma is allowed only at places where an aspect_clause
or compilation_unit
is allowed.
Name Resolution Rules
7/1{8652/0009} In an operational item or representation item, if the local_name
is a direct_name
, then it shall resolve to denote a declaration (or, in the case of a pragma
, one or more declarations) that occurs immediately within the same declarative region as the item. If the local_name
has an attribute_designator
, then it shall resolve to denote an implementation-defined component (see 13.5.1) or a class-wide type implicitly declared immediately within the same declarative region as the item. A local_name
that is a library_unit_name
(only permitted in a representation pragma) shall resolve to denote the library_item
that immediately precedes (except for other pragmas) the representation pragma.
Legality Rules
8/1{8652/0009} The local_name
of an aspect_clause
or representation pragma shall statically denote an entity (or, in the case of a pragma
, one or more entities) declared immediately preceding it in a compilation
, or within the same declarative_part
, package_specification
, task_definition
, protected_definition
, or record_definition
as the representation or operational item. If a local_name
denotes a [local] callable entity, it may do so through a [local] subprogram_renaming_declaration
[(as a way to resolve ambiguity in the presence of overloading)]; otherwise, the local_name
shall not denote a renaming_declaration
.
component_list
(in which case the representation item specifies the representation of components of all objects of the type). It also prevents the problem of renamings of things like “P.all” (where P is an access-to-subprogram value) or “E(I)” (where E is an entry family).declarative_part
whose local_name
is P. The fact that the representation item has to appear in the same declarative_part
as P is a Name Resolution Rule, whereas the fact that the representation item has to appear in the same declarative_part
as Q is a Legality Rule. This is subtle, but it seems like the least confusing set of rules. component_clause
s. See 13.5.1, “Record Representation Clauses”. The representation of an object consists of a certain number of bits (the size of the object). For an object of an elementary type, these are the bits that are normally read or updated by the machine code when loading, storing, or operating-on the value of the object. For an object of a composite type, these are the bits reserved for this object, and include bits occupied by subcomponents of the object. If the size of an object is greater than that of its subtype, the additional bits are padding bits. For an elementary object, these padding bits are normally read and updated along with the others. For a composite object, it is unspecified whether padding bits are read or updated in any given composite operation .
subtype S is Integer range 1..256;
type A is array(Natural range 1..4) of S
with Pack;
X : S := 3;
Y : A := (1, 2, 3, 4);
A representation item directly specifies a representation aspect of the entity denoted by the local_name
, except in the case of a type-related representation item, whose local_name
shall denote a first subtype, and which directly specifies an aspect of the subtype's type. A representation item that names a subtype is either subtype-specific (Size, Object_Size, and Alignment clauses) or type-related (all others).
enumeration_representation_clause
specifies the coding aspect. A record_representation_clause
(without the mod_clause
) specifies the record layout aspect. Each representation pragma specifies a separate aspect. at_clause
or a mod_clause
specify separate aspects, because these are equivalent to attribute_definition_clause
s. See J.7, “At Clauses”, and J.8, “Mod Clauses”.enumeration_representation_clause
10.hrecord_representation_clause
10.i- Component_Size clause
- This paragraph was deleted.{8652/0009}
- Small clause
- Bit_Order clause
- Storage_Pool clause
- Storage_Size clause
- {8652/0009} Stream_Size clause
- {8652/0009} pragma Unchecked_Union
- This paragraph was deleted.{8652/0009}
- This paragraph was deleted.{8652/0009}
- Machine_Radix clause
- pragma Pack
- pragmas Import, Export, and Convention (when applied to a type)
- pragmas Atomic, Independent, and Volatile (when applied to a type)
- pragmas Atomic_Components, Independent_Components, and Volatile_Components (when applied to a type)
- pragma Discard_Names (when applied to an enumeration or tagged type)
- pragmas Priority and Interrupt_Priority (when applied to a task or protected type)
- pragma CPU (when applied to a task or protected type)
- pragma Dispatching_Domain
- pragma Relative_Deadline (when applied to a task or protected type)
- Address clause (applies to objects and program units)
- Alignment clause (when applied to an object)
- Size clause (when applied to an object)
- pragma Inline (applies to subprograms)
- pragmas Import, Export, and Convention (when applied to anything other than a type)
- pragmas Atomic and Volatile (when applied to an object or a component)
- pragmas Atomic_Components, Independent_Components, and Volatile_Components (when applied to an array object)
- pragma Discard_Names (when applied to an exception)
- pragma Asynchronous (applies to procedures)
- pragma No_Return (applies to subprograms)
- pragmas Attach_Handler and Interrupt_Handler (apply to protected units)
- pragmas Priority and Interrupt_Priority (when applied to a subprogram)
- pragma CPU (when applied to a subprogram)
- pragma Relative_Deadline (when applied to a subprogram)
aspect_specification
is not a representation item, a similar categorization applies to the aspect that corresponds to each of these representation items. In addition, there are representation aspects that do not have associated representation items .- aspect Static (applies to expression functions)
- aspect Synchronization (applies to procedures)
- aspects Link_Name and External_Name (when applied to anything other than a type)
- aspect Max_Entry_Queue_Length (when applied to an entry)
{8652/0009} An operational item directly specifies an operational aspect of the entity denoted by the local_name
, except in the case of a type-related operational item, whose local_name
shall denote a first subtype, and which directly specifies an aspect of the type of the subtype.
Aspects that can be specified for types and subtypes are also classified into type-related or subtype-specific aspects. Representation aspects that can be specified for types and subtypes are considered type-related unless specified otherwise. In contrast, the classification of operational aspects are given with the definition of the aspect. Type-related aspects have the same value for all subtypes of (a view of) a type[, while subtype-specific aspects may differ for different subtypes of the same type].
A representation item or operational item that directly specifies an aspect of an entity shall appear before the entity is frozen (see 13.14).
{8652/0009} A representation aspect of a subtype or type shall not be specified (whether by a representation item or an aspect_specification
) before the type is completely defined (see 3.11.1).
If a representation item, operational item, library unit pragma (see J.15), or aspect_specification
is given that directly specifies an aspect of an entity, then it is illegal to give another representation item, operational item, library unit pragma, or aspect_specification
that directly specifies the same aspect of the entity.
pragma
Priority. Priority is not a representation pragma, and as such is neither a representation item nor an aspect_specification
. Regardless, giving both a pragma
Priority and an aspect_specification
for Priority is illegal. We didn't want to complicate the wording solely to support obsolescent features. Unless otherwise specified, it is illegal to specify an operational or representation aspect of a generic formal parameter.
aspect_specification
s, representation items, and operational items are all covered by this rule . A by-reference primitive is a user-defined primitive subprogram for a type T that has an access result designating type T, or that has a formal parameter that is an access parameter designating type T or is aliased and of type T. It is illegal to specify a nonconfirming type-related representation aspect for an untagged type T if it is derived from a by-reference type or inherits one or more by-reference primitives, or if one or more types have been derived from T prior to the specification of the aspect and type T is a by-reference type or defines one or more by-reference primitives that are inherited by these descendants .
{8652/0009} {8652/0011} If a type-related aspect is defined for the partial view of a type, then it has the same definition for the full view of the type, except for certain Boolean-valued operational aspects where the language specifies that the partial view can have the value False even when the full view has the value True. Type-related aspects [cannot be specified, and] are not defined for an incomplete view of a type. Representation aspects of a generic formal parameter are the same as those of the actual. Specification of a type-related representation aspect is not allowed for a descendant of a generic formal untagged type.
incomplete_type_declaration
s and formal_incomplete_type_declaration
s do not allow for an aspect_specification
. The prefix
of an attribute_reference
cannot name an incomplete type (see 3.10.1), so no attribute_definition_clause
can be used with an incomplete type. Similarly, the local_name
of a representation pragma cannot name an incomplete type, so no such pragmas can be used with an incomplete type. The specification of the Size aspect for a given subtype, or the size or storage place for an object (including a component) of a given subtype, shall allow for enough storage space to accommodate any value of the subtype.
{8652/0009} The specification of certain language-defined aspects is not required to be supported by all implementations; in such an implementation, the specification for such an aspect is illegal or raises an exception at run time.
A type_declaration
is illegal if it has one or more progenitors, and a nonconfirming value was specified for a representation aspect of an ancestor, and this conflicts with the representation of some other ancestor. The cases that cause conflicts are implementation defined.
type_declaration
.aspect_specification
. For instance: package Pkg1 is
type Ifc is interface;
type T is tagged record
Fld : Integer;
end record;
for T use record
Fld at 0 range 0 .. Integer'Size - 1;
end record;
end Pkg1;
with Pkg1;
package Pkg2 is
type NewT is new Pkg1.T and Pkg1.Ifc with null record;
end Pkg2;
type_declaration
s where one of its ancestors had a nonconfirming representation value specified. An implementation must ensure that the default representations of ancestors cannot conflict. When specifying an aspect that denotes a subprogram, the profile of the subprogram shall be mode conformant with the one required for the aspect, and the convention shall be Ada. Additional requirements are defined for particular aspects.
aspect_specification
s, this rule applies to attribute_definition_clause
s for those aspects that have associated attributes.type T is ...
with Read => R;
Static Semantics
16/5If two subtypes statically match, then their subtype-specific aspects (for example, Size and Alignment) are the same.
package P1 is
subtype S1 is Integer range 0..2**16-1
with Size => 16; -- Illegal!
-- S1'Size would be 16 by default.
type A1 is access all S1;
X1: A1;
end P1;
16.d/5package P2 is
subtype S2 is Integer range 0..2**16-1
with Size => 32; -- Illegal!
type A2 is access all S2;
X2: A2;
end P2;
16.e/3procedure Q is
use P1, P2;
type Array1 is array(Integer range <>) of aliased S1
with Pack;
Obj1: Array1(1..100);
type Array2 is array(Integer range <>) of aliased S2
with Pack;
Obj2: Array2(1..100);
begin
X1 := Obj2(17)'Unchecked_Access;
X2 := Obj1(17)'Unchecked_Access;
end Q;
{8652/0040} A derived type inherits each type-related representation aspect of its parent type that was directly specified before the declaration of the derived type, or (in the case where the parent is derived) that was inherited by the parent type from the grandparent type. A derived subtype inherits each subtype-specific representation aspect of its parent subtype that was directly specified before the declaration of the derived type, or (in the case where the parent is derived) that was inherited by the parent subtype from the grandparent subtype, but only if the parent subtype statically matches the first subtype of the parent type. An inherited representation aspect is overridden by a subsequent aspect_specification
or representation item that specifies a different value for the same aspect of the type or subtype.
record_representation_clause
for a record extension does not override the layout of the parent part; if the layout was specified for the parent type, it is inherited by the record extension. derived_type_definition
, then inheritance does not happen for that representation item.aspect_specification
or a later representation item for a derived type, the confirming specification does not override the inherited one. Thus the derived type has both a specified confirming value and an inherited nonconfirming representation value — this means that rules that apply only to nonconfirming representation values still apply to this type.aspect_specification
and the parent type has not yet been frozen, then the inherited aspect might not yet have been resolved and evaluated. The implementation will need to have a mechanism to handle such an aspect. {8652/0040} In contrast, whether type-related operational aspects are inherited by a derived type depends on each specific aspect; unless specified, an operational aspect is not inherited. When type-related operational aspects are inherited by a derived type, aspects that were directly specified by aspect_specification
s or operational items that are visible at any point within the immediate scope of the derived type declaration, or (in the case where the parent is derived) that were inherited by the parent type from the grandparent type, are inherited. An inherited operational aspect is overridden by an aspect_specification
or operational item that specifies the same aspect of the type.
derived_type_definition
, then inheritance does not happen for that operational item.When a type-related operational aspect is inherited, the rules for inheritance depend on the nature of the aspect (see 13.1.1). Unless otherwise specified for a given aspect, these rules are as follows:
- For an operational aspect that is a value, the inherited aspect has the same value;
- For an operational aspect that is a
name
: 17.5/5 - if the
name
denotes one or more primitive subprograms of the type, the inherited aspect is aname
that denotes the corresponding primitive subprogram(s) of the derived type; 17.6/5 - otherwise, the inherited aspect is a
name
that denotes the same entity or entities as the original aspect; 17.7/5 - For an operational aspect that is an identifier specific to the aspect, the inherited aspect is the same identifier;
- For an operational aspect that is an
expression
or anaggregate
, the inherited aspect is a correspondingexpression
oraggregate
where eachname
, value, and identifier follows these same rules for inheritance.
Each aspect of representation of an entity is as follows:
- If the aspect is specified for the entity, meaning that it is either directly specified or inherited, then that aspect of the entity is as specified, except in the case of Storage_Size, which specifies a minimum.
- If an aspect of representation of an entity is not specified, it is chosen by default in an unspecified manner.
{8652/0040} If an operational aspect is specified for an entity (meaning that it is either directly specified or, if type-related or subtype-specific, inherited), then that aspect of the entity is as specified. Otherwise, the aspect of the entity has the default value for that aspect.[ For aspects that are neither type-related nor subtype-specific, the terms “specified” and “directly specified” are equivalent.]
An aspect_specification
or representation item that specifies a representation aspect that would have been chosen in the absence of the aspect_specification
or representation item is said to be confirming. The aspect value specified in this case is said to be a confirming representation aspect value. Other values of the aspect are said to be nonconfirming, as are the aspect_specification
s and representation items that specified them. Similarly, an aspect_specification
or operational item that specifies an operational aspect to be the same as the definition it would have by default is said to be confirming; otherwise it is nonconfirming.
Dynamic Semantics
21/1{8652/0009} For the elaboration of an aspect_clause
, any evaluable constructs within it are evaluated.
Implementation Permissions
22/3An implementation may interpret representation aspects in an implementation-defined manner. An implementation may place implementation-defined restrictions on the specification of representation aspects. A recommended level of support is defined for the specification of representation aspects and related features in each subclause. These recommendations are changed to requirements for implementations that support the Systems Programming Annex (see C.2, “Required Representation Support”).
Implementation Advice
23/3The recommended level of support for the specification of all representation aspects is qualified as follows:
- A confirming specification for a representation aspect should be supported.
- An implementation is not required to support the specification for a representation aspect that contains nonstatic expressions, unless each nonstatic expression is a
name
that statically denotes a constant declared before the entity.
- An implementation is not required to support a specification for the Object_Size or Size for a given composite subtype, nor the size or storage place for an object (including a component) of a given composite subtype, unless the constraints on the subtype and its composite subcomponents (if any) are all static constraints.
- An implementation is not required to support specifying a nonconfirming representation aspect value if it can cause an aliased object or an object of a by-reference type to be allocated at a nonaddressable location or, when the alignment attribute of the subtype of such an object is nonzero, at an address that is not an integral multiple of that alignment.
- An implementation is not required to support specifying a nonconfirming representation aspect value if it can cause an aliased object of an elementary type to have a size other than that which would have been chosen by default.
- An implementation is not required to support specifying a nonconfirming representation aspect value if it can cause an aliased object of a composite type, or an object whose type is by-reference, to have a size smaller than that which would have been chosen by default.
- An implementation is not required to support specifying a nonconfirming subtype-specific representation aspect value for an indefinite or abstract subtype.
record_representation_clause
will typically be illegal if it disobeys the above rules. Atomic components have similar restrictions (see C.6, “Shared Variable Control”). For purposes of these rules, the determination of whether specifying a representation aspect value for a type can cause an object to have some property is based solely on the properties of the type itself, not on any available information about how the type is used. In particular, it presumes that minimally aligned objects of this type can be declared at some point.
Incompatibilities With Ada 83
pragma
Pack to A2. Extensions to Ada 83
Wording Changes from Ada 83
type_representation_clause
is removed; the right-hand side of that rule is moved up to where it was used, in aspect_clause
. There are two references to “type representation clause” in RM83, both in Section 13; these have been reworded. Also, the representation_clause
has been renamed the aspect_clause
to reflect that it can be used to control more than just representation aspects.component_clause
s. This is convenient because the rules are almost identical for all of them. We have also defined the new terms “operational item” and “operational aspects” in order to conveniently handle new types of specifiable entities.representation_clause
s don't affect the semantics of the program. One counter-example is the Small clause. Ada 95 has more counter-examples. We have noted the opposite above.Extensions to Ada 95
Wording Changes from Ada 95
representation_clause
was renamed to aspect_clause
.Incompatibilities With Ada 2005
Wording Changes from Ada 2005
aspect_specification
s; generalized operational aspects so that they can be defined for entities other than types. Any extensions are documented elsewhere.Incompatibilities With Ada 2012
Extensions to Ada 2012
Wording Changes from Ada 2012
13.1.1 Aspect Specifications
1/3[Certain representation or operational aspects of an entity may be specified as part of its declaration using an aspect_specification
, rather than using a separate representation or operational item.] The declaration with the aspect_specification
is termed the associated declaration.
Syntax
2/3aspect_specification
::=
with aspect_mark
[=> aspect_definition
] {,
aspect_mark
[=> aspect_definition
] }
3/3aspect_mark
::=
aspect_identifier
['Class]
4/5aspect_definition
::=
name
| expression
| identifier
| aggregate
| global_aspect_definition
Language Design Principles
aspect_specification
is an optional element in most kinds of declarations. Here is a list of all kinds of declarations and an indication of whether or not they allow aspect clauses, and in some cases a short discussion of why (* = allowed, NO = not allowed). Kinds of declarations with no indication are followed by their subdivisions (which have indications).basic_declaration
type_declaration
full_type_declaration
type declaration syntax*
task_type_declaration
*protected_type_declaration
*incomplete_type_declaration
-- NO-- Incomplete types do not have aspects by definition,
-- , so it would not make sense to allow specifying them .
private_type_declaration
*private_extension_declaration
*subtype_declaration
*object_declaration
object declaration syntax*
single_task_declaration
*single_protected_declaration
*number_declaration
-- NOiterated_component_association
-- NOsubprogram_declaration
*abstract_subprogram_declaration
*null_procedure_declaration
*expression_function_declaration
*package_declaration
* -- via package_specification
renaming_declaration
*-- There are no language-defined aspects that may be specified
-- on renames, but implementations might support some.
exception_declaration
*generic_declaration
generic_subprogram_declaration
*generic_package_declaration
* -- via package_specification
generic_instantiation
*enumeration_literal_specification
-- NO-- The syntax would be ambiguous if this was supported directly.
discriminant_specification
*-- There are no language-defined aspects that may be specified
-- on discriminants, but implementations might support some.
component_declaration
*loop_parameter_specification
-- NOchunk_specification
-- NO - the enclosing construct has an aspect_specification
iterator_specification
-- NOiterator_parameter_specification
-- NOparameter_specification
*-- There are no language-defined aspects that may be specified
-- on parameters, but implementations might support some.
subprogram_body
* -- - but language-defined aspects only if there is no explicit specificationentry_declaration
*entry_index_specification
*-- There are no language-defined aspects that may be specified
-- on an entry index, but implementations might support some.
subprogram_body_stub
* -- - but language-defined aspects only if there is no explicit specificationchoice_parameter_specification
-- NOgeneric_formal_parameter_declaration
* formal_object_declaration
*formal_type_declaration
formal_complete_type_declaration
*formal_incomplete_type_declaration
-- NO - see incomplete_type_declaration
above formal_subprogram_declaration
formal_concrete_subprogram_declaration
*formal_abstract_subprogram_declaration
*formal_package_declaration
*extended_return_object_declaration
*-- There are no language-defined aspects that may be specified
-- on return objects, but implementations might support some.
aspect_specification
s on all kinds of bodies, but there are no language-defined aspects-- that may be specified on a body. These are allowed for implementation-defined aspects.
-- See above for subprogram bodies and stubs (as these can be declarations).
package_body
*task_body
*protected_body
*entry_body
*package_body_stub
*task_body_stub
*protected_body_stub
*aspect_specification
s generally are located at the end of declarations. When a declaration is all in one piece such as a null_procedure_declaration
, object_declaration
, or generic_instantiation
the aspect_specification
goes at the end of the declaration; it is then more visible and less likely to interfere with the layout of the rest of the structure. However, we make an exception for program units (other than subprogram specifications) and bodies, in which the aspect_specification
goes before the is. In these cases, the entity could be large and could contain other declarations that also have aspect_specification
s, so it is better to put the aspect_specification
toward the top of the declaration. (Some aspects – such as Pure – also affect the legality of the contents of a unit, so it would be annoying to only see those after reading the entire unit.)Name Resolution Rules
5/5An aspect_mark
identifies an aspect of the entity defined by the associated declaration (the associated entity); the aspect denotes an object, a value, an expression, an aggregate
, a subprogram, or some other kind of entity. If the aspect_mark
identifies:
- an aspect that denotes an object, the
aspect_definition
shall be aname
. The expected type for thename
is the type of the identified aspect of the associated entity; 7/3 - an aspect that is a value or an expression, the
aspect_definition
shall be anexpression
. The expected type for theexpression
is the type of the identified aspect of the associated entity; 7.1/5 - an aspect that is an
aggregate
, the aspect definition shall be anexpression
that is anaggregate
, with the form of theaggregate
determined by the identified aspect;
expression
is syntactically an aggregate
; there is no requirement that it resolve to some particular type or even that it should resolve like an aggregate
. Each aspect that uses an aggregate
is responsible for specifying how the choice(s), component(s), and other contents of the aggregate
are resolved and interpreted. - an aspect that denotes a subprogram, the
aspect_definition
shall be aname
; the expected profile for thename
is the profile required for the aspect of the associated entity; 9/3 - an aspect that denotes some other kind of entity, the
aspect_definition
shall be aname
, and the name shall resolve to denote an entity of the appropriate kind; 10/3 - an aspect that is given by an identifier specific to the aspect, the
aspect_definition
shall be anidentifier
, and theidentifier
shall be one of the identifiers specific to the identified aspect.
The usage names in an aspect_definition
associated with a declaration [ are not resolved at the point of the associated declaration, but rather] are resolved at the end of the immediately enclosing declaration list, or in the case of the declaration of a library unit, at the end of the visible part of the entity.
aspect_specification
is not associated with a declaration (instead being part of a statement
or expression
), then it is resolved when the associated construct is resolved. If the associated declaration is for a subprogram, entry, or access-to-subprogram type, the names of the formal parameters are directly visible within the aspect_definition
, as are certain attributes, as specified elsewhere in this document for the identified aspect. If the associated declaration is a type_declaration
, within the aspect_definition
the names of any visible components, protected subprograms, and entries are directly visible, and the name of the first subtype denotes the current instance of the type (see 8.6). If the associated declaration is a subtype_declaration
, within the aspect_definition
the name of the new subtype denotes the current instance of the subtype.
Legality Rules
13/3If the first freezing point of the associated entity comes before the end of the immediately enclosing declaration list, then each usage name in the aspect_definition
shall resolve to the same entity at the first freezing point as it does at the end of the immediately enclosing declaration list.
An expression
or name
that causes freezing of an entity shall not occur within an aspect_specification
that specifies a representation or operational aspect of that entity.
aspect_definition
is not resolved until then), and might be accomplished during the freezing of the aspect_definition
(since it is closely related). Keep in mind that multiple other entities could be involved. At most one occurrence of each aspect_mark
is allowed within a single aspect_specification
. The aspect identified by the aspect_mark
shall be an aspect that can be specified for the associated entity (or view of the entity defined by the associated declaration).
aspect_specification
. Rules in 13.1 prevent multiple specifications in different aspect_specification
s (on different views of the same type, for instance), or between operational or representation items and an aspect_specification
. The aspect_definition
associated with a given aspect_mark
may be omitted only when the aspect_mark
identifies an aspect of a boolean type, in which case it is equivalent to the aspect_definition
being specified as True.
If the aspect_mark
includes 'Class, then the associated entity shall be a tagged type or a primitive subprogram of a tagged type.
Unless otherwise specified for a specific aspect, a language-defined aspect cannot be specified on a renaming_declaration
or a generic_formal_parameter_declaration
.
Unless specified otherwise, a language-defined aspect shall not be specified in an aspect_specification
given on a completion of a program unit .
If an aspect of a derived type is inherited from an ancestor type and has the boolean value True, the inherited value shall not be overridden to have the value False for the derived type, unless otherwise specified in this document.
If a given aspect is type-related and inherited, then within an aspect_definition
for the aspect, if a name
resolves to denote multiple visible subprograms, all or none of the denoted subprograms shall be primitives of the associated type.
Certain type-related aspects are defined to be nonoverridable; all such aspects are inherited by derived types according to the rules given in 13.1. Any legality rule associated with a nonoverridable aspect is re-checked for the derived type, if the derived type is not abstract. Certain type-related and subtype-specific aspects are defined to be additive; such aspects are not inherited, but they can apply to the types derived from, or the subtypes based on, the original type or subtype, as defined for each such aspect. Finally, certain type-related aspects are implicitly composed; such aspects are not inherited, but rather a default implementation for a derived type is provided, as defined for each such aspect, based on that of its parent type, presuming the aspect for the parent type is available where the derived type is declared, plus those of any new components added as part of a type extension.
If a nonoverridable aspect is directly specified for a type T, then any explicit specification of that aspect for any descendant of T (other than T itself) shall be confirming. In the case of an aspect that is a name
, this means that the specified name
shall match the inherited aspect in the sense that it shall denote the same declarations as would the inherited name
. Similarly, for an aspect that is an expression
or an aggregate
, confirming means the defining expression
is fully conformant (see 6.3.1) with the defining expression
for the inherited aspect, with the added rule that an identifier that is specific to the aspect is the same as the corresponding identifier in the inherited aspect.
If a full type has a partial view, and a given nonoverridable aspect is allowed for both the full view and the partial view, then the given aspect for the partial view and the full view shall be the same: the aspect shall be directly specified only on the partial view; if the full type inherits the aspect, then a matching definition shall be specified (directly or by inheritance) for the partial view.
If a type inherits a nonoverridable aspect from multiple ancestors, the value of the aspect inherited from any given ancestor shall be confirming of the values inherited from all other ancestors.
In addition to the places where Legality Rules normally apply (see 12.3), these rules about nonoverridable aspects also apply in the private part of an instance of a generic unit.
Static Semantics
19/3Depending on which aspect is identified by the aspect_mark
, an aspect_definition
specifies:
- a
name
that denotes a subprogram, object, or other kind of entity; 21/5 - an
expression
(other than anaggregate
), which is either evaluated to produce a single value, or which (as in a precondition) is to be evaluated at particular points during later execution; 22/5 - an
identifier
specific to the aspect; or 22.1/5 - an
aggregate
, which is positional or named, and is composed of elements of any of these four kinds of constructs.
The identified aspect of the associated entity, or in some cases, the view of the entity defined by the declaration, is as specified by the aspect_definition
(or by the default of True when boolean). Whether an aspect_specification
applies to an entity or only to the particular view of the entity defined by the declaration is determined by the aspect_mark
and the kind of entity. The following aspects are view specific:
- An aspect specified on an
object_declaration
; 25/3 - An aspect specified on a
subprogram_declaration
; 26/3 - An aspect specified on a
renaming_declaration
.
All other aspect_specification
s are associated with the entity, and apply to all views of the entity, unless otherwise specified in this document.
If the aspect_mark
includes 'Class (a class-wide aspect), then, unless specified otherwise for a particular class-wide aspect:
- if the associated entity is a tagged type, the specification applies to all descendants of the type;
- if the associated entity is a primitive subprogram of a tagged type T, the specification applies to the corresponding primitive subprogram of all descendants of T.
All specifiable operational and representation attributes may be specified with an aspect_specification
instead of an attribute_definition_clause
(see 13.3).
aspect_mark
is the attribute_designator
of the attribute.attribute_definition_clause
also apply to an aspect_specification
for the aspect. These are enforced at the freezing point of the entity. For example, when specifying the Size aspect of a subtype, the expression has to be a static expression with an integer type and a nonnegative value, all of the recommended level of support requirements apply if Annex C is supported (see C.2), and so on. Some aspects are defined to be library unit aspects. Library unit aspects are of type Boolean. The expression specifying a library unit aspect shall be static. Library unit aspects are defined for all program units, but shall be specified only for library units. Notwithstanding what this document says elsewhere, the expression of a library unit aspect is resolved and evaluated at the point where it occurs in the aspect_specification
[, rather than the first freezing point of the associated unit ].
aspect_mark
is the name of the pragma. In addition, other operational and representation aspects not associated with specifiable attributes or representation pragmas may be specified, as specified elsewhere in this document.
This paragraph was deleted.
If a Legality Rule or Static Semantics rule only applies when a particular aspect has been specified, the aspect is considered to have been specified only when the aspect_specification
or attribute_definition_clause
is visible (see 8.3) at the point of the application of the rule.
Alternative legality and semantics rules may apply for particular aspects, as specified elsewhere in this document.
Dynamic Semantics
37/5At the freezing point of the associated entity, the aspect_specification
is elaborated. When appearing in a construct other than a declaration, an aspect_specification
is elaborated as part of the execution of the construct. The elaboration of the aspect_specification
consists of the elaboration of each aspect_definition
in an arbitrary order. The elaboration of an aspect_definition
includes the evaluation of any name
or expression
that is part of the aspect_definition
unless the part is itself an expression. If the corresponding aspect (or part thereof) represents an expression (as in a precondition), the elaboration of that part has no effect; the expression is evaluated later at points within the execution as specified elsewhere in this document for the particular aspect.
Implementation Permissions
38/3Implementations may support implementation-defined aspects. The aspect_specification
for an implementation-defined aspect may use an implementation-defined syntax for the aspect_definition
, and may follow implementation-defined legality and semantics rules.
subtype_indication
rather than an expression
or a name
. We chose not to try to enumerate all possible aspect_definition
syntaxes, but to give implementations maximum freedom. An implementation may ignore the specification of an unrecognized aspect; if an implementation chooses to ignore such an aspect specification (as opposed to rejecting it), then it has no effect on the semantics of the program except for possibly (and this is not required) the rejection of syntax errors within the aspect_definition
.
aspect_definition
for an unrecognized aspect may be challenging, particularly if the syntax for the unrecognized aspect's aspect_definition
is implementation-defined. It is not specified how an implementation might accomplish this. Note that an implementation is never required to be able to do this; if an aspect_definition
for an unrecognized aspect is problematic in any way, then it can always be rejected (as opposed to being ignored). Extensions to Ada 2005
Inconsistencies With Ada 2012
Incompatibilities With Ada 2012
Extensions to Ada 2012
aggregate
, these can be used to specify a list of entities, or to set a group of different but related properties with a single aspect.Wording Changes from Ada 2012
entry_body
to the list of entities that don't allow any language-defined aspects. This was an oversight in which allowed aspect_specification
s on an entry_body
in the first place.aspect_specification
s not associated with a declaration occur.