Version 1.5 of ais/ai-00002.txt

Unformatted version of ais/ai-00002.txt version 1.5
Other versions for file ais/ai-00002.txt

!standard 10.02.01 (11)          99-10-08 AI95-00002/04
!class binding interpretation 95-06-25
!status Corrigendum 2000 99-05-24
!status WG9 approved 95-06-14
!status ARG approved (subject to editorial review) 9-0-2 95-11-01
!status received 95-06-25
!qualifier Error
!subject Subunits of a preelaborated subprogram
!summary
A subunit which is not elaborated as part of elaborating a preelaborated library unit need not be preelaborable.
!question
10.2.1(11) says, "All compilation units of a preelaborated library unit shall be preelaborable." The term "all compilation units" includes subunits. Is this really intended? (No.)
!recommendation
(See summary.)
!wording
(See corrigendum.)
!discussion
It is unnecessary to require a subunit of a preelaborated subprogram to be preelaborable, because such a subunit is not elaborated during elaboration of the subprogram. This also applies to subunits of preelaborated tasks and any other unit which does not elaborate its contents when it is elaborated.
Furthermore, subunits and physically nested program units should behave in the same way. If a subprogram is preelaborated, packages physically nested within the subprogram need not be preelaborable; therefore, the same should be true of package subunits.
Note that a subunit of a preelaborated package is required to be preelaborable even without the quoted sentence, because such a subunit is elaborated during elaboration of the parent package, and the definition of preelaborability in 10.2.1(5) says, "... unless its elaboration performs...", which makes the rule transitive.
The proposed change to the rule makes it always the case that subunits and physically nested program units behave the same, even in the face of nesting or multiple levels of subunits.
Note that the rule is irrelevant for subunits that are subprograms, since subprograms are always preelaborable. But it is relevant for package and other subunits.
!corrigendum 10.02.01(11)
Replace the paragraph:
If a pragma Preelaborate (or pragma Pure -- see below) applies to a library unit, then it is preelaborated. If a library unit is preelaborated, then its declaration, if any, and body, if any, are elaborated prior to all non-preelaborated library_items of the partition. All compilation units of a preelaborated library unit shall be preelaborable. In addition to the places where Legality Rules normally apply (see 12.3), this rule applies also in the private part of an instance of a generic unit. In addition, all compilation units of a preelaborated library unit shall depend semantically only on compilation units of other preelaborated library units.
by:
If a pragma Preelaborate (or pragma Pure -- see below) applies to a library unit, then it is preelaborated. If a library unit is preelaborated, then its declaration, if any, and body, if any, are elaborated prior to all non-preelaborated library_items of the partition. The declaration and body of a preelaborated library unit, and all subunits that are elaborated as part of elaborating the library unit, shall be preelaborable. In addition to the places where Legality Rules normally apply (see 12.3), this rule applies also in the private part of an instance of a generic unit. In addition, all compilation units of a preelaborated library unit shall depend semantically only on compilation units of other preelaborated library units.
!ACATS test
Test CA21001 checks that the newly allowed case is supported. Test BA21004 checks that only this permission is allowed.
!appendix

!section 10.2.1(11)
!subject Compilation units "of" a library unit
!reference RM9X-10.2.1(11);5.95
!from Norman Cohen
!reference as: 94-5029.c Norman H. Cohen 94-12-13>>
!discussion

"All compilation units of a preelaborated library unit shall be
preelaborable."

Presumably the compilation units "of" a library unit are the library unit
itself, the body, if any, and all subunits descended from the body.

But then a subunit of a preelaborated subprogram is required to be
preelaborable, which does not seem necessary since elaboration of the
subprogram does not entail elaboration of the subunit.

****************************************************************

!section 10.2.1(11)
!subject Compilation units "of" a library unit
!reference RM9X-10.2.1(11);5.95
!reference 94-5029.c Norman H. Cohen 94-12-13
!from Tucker Taft 94-12-14
!reference as: 94-5030.c Tucker Taft 94-12-14>>
!discussion

> "All compilation units of a preelaborated library unit shall be
> preelaborable."
>
> Presumably the compilation units "of" a library unit are the library unit
> itself, the body, if any, and all subunits descended from the body.
>
> But then a subunit of a preelaborated subprogram is required to be
> preelaborable, which does not seem necessary since elaboration of the
> subprogram does not entail elaboration of the subunit.

Good point.  For a package subunit of a subprogram, this
requirement seems overly restrictive.  What we wanted to ensure
was that the subunit depended semantically only on other
preelaborated units.

****************************************************************

From: Randy Brukardt
Sent: October 8, 1999

At the recent ARG meeting, it was determined that this rule was not broad
enough. A subunit nested in a task should also not be required to be
preelaboratable. Similarly, a subunit of a subunit may not need to be
preelaboratable.

A rule based on equivalence of behavior of nested units and subunits was
adopted. I've rewritten the AI to reflect this change.

****************************************************************

Questions? Ask the ACAA Technical Agent