Version 1.1 of ais/ai-00180.txt

Unformatted version of ais/ai-00180.txt version 1.1
Other versions for file ais/ai-00180.txt

!standard 10.01.02 (06)          97-05-27 AI95-00180/03
!class confirmation 97-03-19
!status WG9 approved (8-0-0) 97-07-04
!status ARG approved (8-0-2) 97-04-11
!status work item 97-03-19
!status received 97-03-19
!priority Medium
!difficulty Easy
!subject Pragma Elaborate for Child Units
!summary 97-03-19
A pragma Elaborate on a child unit does not imply an elaboration dependence upon the parent of that child unit.
!question 97-05-08
10.2(9) says:
The order of elaboration of library units is determined primarily by the elaboration dependences. ... In addition, if a given library_item or ... has a pragma Elaborate ... that MENTIONS another library_unit, then there is an elaboration dependence of the given library_item upon the body of the other library_unit, ...
Is the term "mentioned" meant to be defined by 10.1.2(6):
A library_item is MENTIONED in a with_clause if it is denoted by a library_unit_name or a prefix in the with_clause.
? (No.) If so, it would imply that a pragma Elaborate on a child unit causes an elaboration dependence upon the parent of that child unit (as well as on the child unit itself). Is this the intent? (No.)
!response 97-05-08
The intent is that 10.1.2(6) is defining "mentioned in a with_clause", not "mentioned" in general. The term "mentioned" in 10.2(9) is used in an informal sense; it merely means the library unit to which the pragma applies, and not its parent.
10.2.1(26) clarifies this:
A pragma Elaborate specifies that the body of the named library unit is elaborated before the current library_item.
If transitive semantics is desired, then pragma Elaborate_All should be used.
!appendix

!section 10.1.2(06)
!subject Elaboration Pragmas & "Mentions"
!reference RM95-10.1.2(6)
!reference RM95-10.2(9)
!reference RM95-10.2.1(26)
!reference 97-15724.a Dan Lehman 97-2-24>>
!discussion

There's a conflict between the rules for elaboration dependences and
what's implied for pragma Elaborate.  The former imply that a pragma
Elaborate elaborates all of the *mentioned* units' bodies, whereas
the latter specifies only the named unit's body.

10.2(9) says:

     The order of elaboration of library units is determined
     primarily by the elaboration dependences.  ... In addition,
     if a given library_item or ... has a pragma Elaborate ...
     that MENTIONS another library_unit, then there is an elaboration
     dependence of the given library_item upon the body of the other
     library_unit, ...

10.1.2(6) defines "mentioned" (note that although the index entry reads
"mentioned in a with_clause", only m. is italicized) as:

     A library_item is MENTIONED in a with_clause if it is denoted
     by a library_unit_name or a prefix in the with_clause.

This appears to be the sole definition of "mentions"; one then naturally
applies it to the 10.2(9) passage quoted above.

But 10.2.1(26) says:

     A pragma Elaborate specifies that the body of the named library
     unit is elaborated before the current library_item.

Thus 10.2.1(26) and 10.2(9) give conflicting accounts of what the elaboration
dependences are in the case where a pragma Elaborate applies to a child unit
--is the dependence on just the child, or also on the *mentioned* parent?
It seems that either 10.2(9) should use "applies" or 10.2.1(26) should use
"mentioned".

Below is a response to this query by Gary Dismukes, followed by code that
highlights the issue--it tests for adherence to 10.2(9).


:::::: From dismukes@gnat.com Wed Feb  5 22:07:16 1997 :::::::::::::::::::::

It looks like conflicting wording to me as well.  It seems to me
that the use of the word "mentions" in 10.2(9) is unintended.
That is, I don't believe it's intended that a pragma Elaborate
should cause not only a child unit body but also its parent's body
to be elaborated before the unit.  This would provide a distinct
lack of flexibility in the use of the pragma.  It could easily
introduce unresolvable circularities (e.g., consider a case where
a child unit needs to elaborate one of its siblings bodies, but
the parent body also depends on the child).  So I really don't
think the semantics implied by 10.2(9) can be intended, and
10.2.1(26) should take precedence.

This looks to me like a minor wording issue for the ARG to resolve.

-- Gary
::::::::

----------------------------------------------------------------------------

package Parent is
   type elabbed_type
    is (P_spec_elabbed, P_body_elabbed);
   elab_status: elabbed_type := P_spec_elabbed;
   function Require_Body return Boolean;
  end;

package Parent.Child is
     ...
  end;
--===================================
  with Parent.Child;
  pragma Elaborate (Parent.Child);  --*MENTIONS* P. => DEPENDS ON P.BODY
package Importer is
     parent_elab_status: Parent.elabbed_type := Parent.elab_status;
  end;
--===================================
package body Parent is
    function Require_Body is begin return TRUE;  end Require_Body;
  begin
        elab_status := P_body_elabbed;
  end Parent;
--===================================
  with Parent.Child;
  with Importer;
procedure Check_Parent_Elab_Status is
   begin
      if    Importer.Parent_elab_status /= Parent.elab_status
         OR Parent.elab_status /=  P_body_elabbed
        then
           Report.Failed ("10.2:9 elab. dependence was not recognized");
      end if;
   end Check_Parent_Elab_Status;

==============================================================================




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

Questions? Ask the ACAA Technical Agent