AI22-0137-1
!standard 3.10.1(8.1/3) 25-08-15 AI22-0137-1/04
!standard 3.10.1(8.4/3)
!class Binding Interpretation 25-06-30
!status Revision-202Y 25-07-30
!status WG9 Approved 25-10-08
!status ARG Approved 15-0-1 25-07-30
!status work item 25-06-30
!status received 25-06-30
!assigned author Stephen Baird
!submitter Stephen Baird
!priority Low
!difficulty Easy
!qualifier Omission
!subject Renaming-as-body with a parameter of an incomplete type
A renaming-as-body is illegal if the subprogram has an untagged incomplete parameter or any incomplete result type.
We do not require implementations to use a wrapper model for implementing renamings-as-body, but we do want to allow that option. Allowing cases where that approach does not work introduces problems for implementations that choose that implementation strategy.
Therefore, a renaming-as-body should be illegal if an equivalent explicit wrapper subprogram would violate the rule about uses of incomplete parameter types in the profile of a subprogram when the subprogram is called. Specifically, RM 3.10.1(10/3): “An actual parameter in a call shall not be of an untagged incomplete view".
For a specific example, suppose we have:
[This is shown as code in the Example section below, that might be easier to understand.]
Should that renaming-as-body be legal? (No.)
In effect, apply the existing 3.10.1(10/3) rule about explicit calls to the implicit call associated with an implicitly-declared wrapper subprogram. This effect is achieved by modifying the rules about how an incomplete view of a type can be used.
Modify 3.10.1(8.1/3):
Modify 3.10.1(8.4/3):
At least one production Ada compiler has run into the problem described in this AI.
Note that this problem does not occur for parameters of tagged incomplete types. A call passing an object of such a type is legal (as the details of parameter passing are known for such types). This is not true for results of a tagged incomplete type.
package P1 is
type T is ...; -- untagged
end P1;
---
limited with P1;
package P2 is
procedure Proc (Arg : P1.T);
end P2;
---
limited with P1;
package P3 is
procedure Proc (Arg : P1.T);
end P3;
---
with P3;
package body P2 is
procedure Proc (Arg : P1.T) renames P3.Proc; -- Legal? (No.)
end P2;
@drepl
@xbullet{as the @fa{subtype_mark} defining the subtype of a parameter or result in a profile occurring within a @fa{basic_declaration}; }
@dby
@xbullet{as the @fa{subtype_mark} defining the subtype of a parameter or result in a profile occurring within a @fa{basic_declaration} other than a renaming-as-body (see @ref{8.5.4}); }
@drepl
@xbullet{as the @fa{subtype_mark} defining the subtype of a parameter in the profile for a @fa{subprogram_body}, @fa{entry_body}, or @fa{accept_statement};}
@dby
@xbullet{as the @fa{subtype_mark} defining the subtype of a parameter in the profile for a @fa{subprogram_body}, @fa{entry_body}, @fa{accept_statement}, or renaming-as-body;}
An ACATS B-test similar to the above example would be appropriate.