Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
 
Ada Reference Manual (Ada 2022)Legal Information
Contents   Index   References   Search   Previous   Next 

6.3.1 Conformance Rules

1
When subprogram profiles are given in more than one place, they are required to conform in one of four ways: type conformance, mode conformance, subtype conformance, or full conformance. 

Static Semantics

2/1
As explained in B.1, “Interfacing Aspects”, a convention can be specified for an entity. Unless this document states otherwise, the default convention of an entity is Ada. For a callable entity or access-to-subprogram type, the convention is called the calling convention. The following conventions are defined by the language: 
3/3
The default calling convention for any subprogram not listed below is Ada. The Convention aspect may be specified to override the default calling convention (see B.1). 
4
The Intrinsic calling convention represents subprograms that are “built in” to the compiler. The default calling convention is Intrinsic for the following: 
5
an enumeration literal;
6
a "/=" operator declared implicitly due to the declaration of "=" (see 6.6);
7
any other implicitly declared subprogram unless it is a dispatching operation of a tagged type;
8
an inherited subprogram of a generic formal tagged type with unknown discriminants; 
9
an attribute that is a subprogram;
10/2
a subprogram declared immediately within a protected_body;
10.1/4
any prefixed view of a subprogram (see 4.1.3) without synchronization kind (see 9.5) By_Entry or By_Protected_Procedure.
11
The Access attribute is not allowed for Intrinsic subprograms. 
12/4
The default calling convention is protected for a protected subprogram, for a prefixed view of a subprogram with a synchronization kind of By_Protected_Procedure, and for an access-to-subprogram type with the reserved word protected in its definition.
13/4
The default calling convention is entry for an entry and for a prefixed view of a subprogram with a synchronization kind of By_Entry.
13.1/5
The calling convention for an anonymous access-to-subprogram parameter or anonymous access-to-subprogram result is protected if the reserved word protected appears in its definition; otherwise, it is the convention of the entity that has the parameter or result, unless that entity has convention protected, entry, or Intrinsic, in which case the convention is Ada. 
13.2/1
If not specified above as Intrinsic, the calling convention for any inherited or overriding dispatching operation of a tagged type is that of the corresponding subprogram of the parent type. The default calling convention for a new dispatching operation of a tagged type is the convention of the type. 
14/3
Of these four conventions, only Ada and Intrinsic are allowed as a convention_identifier in the specification of a Convention aspect. 
15/2
Two profiles are type conformant if they have the same number of parameters, and both have a result if either does, and corresponding parameter and result types are the same, or, for access parameters or access results, corresponding designated types are the same, or corresponding designated profiles are type conformant.
16/3
Two profiles are mode conformant if:
16.1/3
they are type conformant; and
16.2/3
corresponding parameters have identical modes and both or neither are explicitly aliased parameters; and
16.3/3
for corresponding access parameters and any access result type, the designated subtypes statically match and either both or neither are access-to-constant, or the designated profiles are subtype conformant.
17/3
Two profiles are subtype conformant if they are mode conformant, corresponding subtypes of the profile statically match, and the associated calling conventions are the same. The profile of a generic formal subprogram is not subtype conformant with any other profile.
18/3
Two profiles are fully conformant if they are subtype conformant, if they have access-to-subprogram results whose designated profiles are fully conformant, and for corresponding parameters: 
18.1/3
they have the same names; and
18.2/3
both or neither have null_exclusions; and
18.3/3
neither have default_expressions, or they both have default_expressions that are fully conformant with one another; and
18.4/3
for access-to-subprogram parameters, the designated profiles are fully conformant. 
19
Two expressions are fully conformant if, after replacing each use of an operator with the equivalent function_call:
20
each constituent construct of one corresponds to an instance of the same syntactic category in the other, except that an expanded name may correspond to a direct_name (or character_literal) or to a different expanded name in the other; and
20.1/4
corresponding defining_identifiers occurring within the two expressions are the same; and
21/4
each direct_name, character_literal, and selector_name that is not part of the prefix of an expanded name in one denotes the same declaration as the corresponding direct_name, character_literal, or selector_name in the other, or they denote corresponding declarations occurring within the two expressions; and 
21.1/3
each attribute_designator in one is the same as the corresponding attribute_designator in the other; and
22/5
each primary that is a literal in one is a user-defined literal if and only if the corresponding literal in the other is also a user-defined literal. Furthermore, if neither are user-defined literals then they shall have the same values, but they may have differing textual representations; if both are user-defined literals then they shall have the same textual representation.
23
Two known_discriminant_parts are fully conformant if they have the same number of discriminants, and discriminants in the same positions have the same names, statically matching subtypes, and default_expressions that are fully conformant with one another.
24
Two discrete_subtype_definitions are fully conformant if they are both subtype_indications or are both ranges, the subtype_marks (if any) denote the same subtype, and the corresponding simple_expressions of the ranges (if any) fully conform. 
24.1/2
  The prefixed view profile of a subprogram is the profile obtained by omitting the first parameter of that subprogram. There is no prefixed view profile for a parameterless subprogram. For the purposes of defining subtype and mode conformance, the convention of a prefixed view profile is considered to match that of either an entry or a protected operation.

Implementation Permissions

25
An implementation may declare an operator declared in a language-defined library unit to be intrinsic. 
26/5
NOTE   Any conformance requirements between aspect_specifications that are part of a profile or known_discriminant_part are defined by the semantics of each particular aspect. In particular, there is no general requirement for aspect_specifications to match in conforming profiles or discriminant parts. 

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