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.4.1 Parameter Associations

1
A parameter association defines the association between an actual parameter and a formal parameter. 

Name Resolution Rules

2/3
The formal_parameter_selector_name of a named parameter_association shall resolve to denote a parameter_specification of the view being called; this is the formal parameter of the association. The formal parameter for a positional parameter_association is the parameter with the corresponding position in the formal part of the view being called.
3
The actual parameter is either the explicit_actual_parameter given in a parameter_association for a given formal parameter, or the corresponding default_expression if no parameter_association is given for the formal parameter. The expected type for an actual parameter is the type of the corresponding formal parameter.
4
If the mode is in, the actual is interpreted as an expression; otherwise, the actual is interpreted only as a name, if possible. 

Legality Rules

5
If the mode is in out or out, the actual shall be a name that denotes a variable. 
5.1/5
 If the mode is out, the actual parameter is a view conversion, and the type of the formal parameter is a scalar type, then 
5.2/5
neither the target type nor the operand type has the Default_Value aspect specified; or
5.3/5
both the target type and the operand type shall have the Default_Value aspect specified, and there shall exist a type (other than a root numeric type) that is an ancestor of both the target type and the operand type. 
5.4/4
 In addition to the places where Legality Rules normally apply (see 12.3), these rules also apply in the private part of an instance of a generic unit.
6/3
If the formal parameter is an explicitly aliased parameter, the type of the actual parameter shall be tagged or the actual parameter shall be an aliased view of an object. Further, if the formal parameter subtype F is untagged:
6.1/3
the subtype F shall statically match the nominal subtype of the actual object; or
6.2/3
the subtype F shall be unconstrained, discriminated in its full view, and unconstrained in any partial view. 
6.3/4
 In addition to the places where Legality Rules normally apply (see 12.3), these rules also apply in the private part of an instance of a generic unit.
6.4/3
 In a function call, the accessibility level of the actual object for each explicitly aliased parameter shall not be statically deeper than the accessibility level of the master of the call (see 3.10.2).
6.5/3
 Two names are known to denote the same object if:
6.6/3
both names statically denote the same stand-alone object or parameter; or
6.7/3
both names are selected_components, their prefixes are known to denote the same object, and their selector_names denote the same component; or
6.8/3
both names are dereferences (implicit or explicit) and the dereferenced names are known to denote the same object; or
6.9/3
both names are indexed_components, their prefixes are known to denote the same object, and each of the pairs of corresponding index values are either both static expressions with the same static value or both names that are known to denote the same object; or
6.10/3
both names are slices, their prefixes are known to denote the same object, and the two slices have statically matching index constraints; or
6.11/3
one of the two names statically denotes a renaming declaration whose renamed object_name is known to denote the same object as the other, the prefix of any dereference within the renamed object_name is not a variable, and any expression within the renamed object_name contains no references to variables nor calls on nonstatic functions.
6.12/3
  Two names are known to refer to the same object if
6.13/3
The two names are known to denote the same object; or
6.14/3
One of the names is a selected_component, indexed_component, or slice and its prefix is known to refer to the same object as the other name; or
6.15/3
One of the two names statically denotes a renaming declaration whose renamed object_name is known to refer to the same object as the other name.
6.16/3
  If a call C has two or more parameters of mode in out or out that are of an elementary type, then the call is legal only if:
6.17/5
For each name N denoting an object of an elementary type that is passed as a parameter of mode in out or out to the call C, there is no other name among the other parameters of mode in out or out to C that is known to denote the same object.
6.18/3
  If a construct C has two or more direct constituents that are names or expressions whose evaluation may occur in an arbitrary order, at least one of which contains a function call with an in out or out parameter, then the construct is legal only if:
6.19/3
For each name N that is passed as a parameter of mode in out or out to some inner function call C2 (not including the construct C itself), there is no other name anywhere within a direct constituent of the construct C other than the one containing C2, that is known to refer to the same object. 
6.20/3
  For the purposes of checking this rule:
6.21/3
For an array aggregate, an expression associated with a discrete_choice_list that has two or more discrete choices, or that has a nonstatic range, is considered as two or more separate occurrences of the expression;
6.22/3
For a record aggregate:
6.23/3
The expression of a record_component_association is considered to occur once for each associated component; and
6.24/3
The default_expression for each record_component_association with <> for which the associated component has a default_expression is considered part of the aggregate;
6.25/3
For a call, any default_expression evaluated as part of the call is considered part of the call. 

Dynamic Semantics

7
For the evaluation of a parameter_association:
8
The actual parameter is first evaluated.
9
For an access parameter, the access_definition is elaborated, which creates the anonymous access type.
10
For a parameter (of any mode) that is passed by reference (see 6.2), a view conversion of the actual parameter to the nominal subtype of the formal parameter is evaluated, and the formal parameter denotes that conversion.
11
For an in or in out parameter that is passed by copy (see 6.2), the formal parameter object is created, and the value of the actual parameter is converted to the nominal subtype of the formal parameter and assigned to the formal.
12
For an out parameter that is passed by copy, the formal parameter object is created, and: 
13/5
For an access type, the formal parameter is initialized from the value of the actual, without checking whether the value satisfies any constraints, predicates, or null exclusions, but including any dynamic accessibility checks associated with a conversion to the type of the formal parameter.
13.1/5
For a scalar type that has the Default_Value aspect specified, the formal parameter is initialized from the value of the actual, without checking that the value satisfies any constraint or any predicate.
14/5
For a composite type with discriminants or that has implicit initial values for any subcomponents (see 3.3.1), the behavior is as for an in out parameter passed by copy, except that no predicate check is performed. 
15/5
For any other type, the formal parameter is uninitialized. If composite, a view conversion of the actual parameter to the nominal subtype of the formal is evaluated (which can raise Constraint_Error), and the actual subtype of the formal is that of the view conversion. If elementary, the actual subtype of the formal is given by its nominal subtype. 
15.1/5
Furthermore, if the type is a scalar type, and the actual parameter is a view conversion, then Program_Error is raised if either the target or the operand type has the Default_Value aspect specified, unless they both have the Default_Value aspect specified, and there is a type (other than a root numeric type) that is an ancestor of both the target type and the operand type.
15.2/5
In a function call, for each explicitly aliased parameter, a check is made that the accessibility level of the master of the actual object is not deeper than that of the master of the call (see 3.10.2). 
16
A formal parameter of mode in out or out with discriminants is constrained if either its nominal subtype or the actual parameter is constrained.
17
After normal completion and leaving of a subprogram, for each in out or out parameter that is passed by copy, the value of the formal parameter is converted to the subtype of the variable given as the actual parameter and assigned to it. These conversions and assignments occur in an arbitrary order. 

Erroneous Execution

18/3
If the nominal subtype of a formal parameter with discriminants is constrained or indefinite, and the parameter is passed by reference, then the execution of the call is erroneous if the value of any discriminant of the actual is changed while the formal parameter exists (that is, before leaving the corresponding callable construct). 

Implementation Permissions

19/5
If the actual parameter in a parameter_association with mode out is a view conversion between two access types that do not share a common ancestor type, the implementation may pass in the null value of the type of the formal parameter instead of the value of the actual parameter. It is implementation-defined under what circumstances the implementation passes in the null value. 

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