From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,16e3a8dd4f3ab3f3 X-Google-Attributes: gid103376,public From: stt@henning.camb.inmet.com (Tucker Taft) Subject: Re: Elaboration order Date: 1996/03/20 Message-ID: #1/1 X-Deja-AN: 143389222 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: henning.camb.inmet.com references: <4io8rn$gfn@newsbf02.news.aol.com> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-03-20T00:00:00+00:00 List-Id: DenReimer (denreimer@aol.com) wrote: : Here's something that I'm trying to do in Ada83 and Ada95: : with GENERIC_PACKAGE; : package A_PKG is : package INSTANCE is new GENERIC_PACKAGE ( ... ); : X : INTEGER := INSTANCE.SOME_FUNCTION; : end A_PKG; : The elaboration of X requires that the instantiated package INSTANCE be : elaborated first (both spec and body.) The compiler will not let me use : pragma elaborate (INSTANCE); You should write: with Generic_Package; pragma Elaborate(Generic_Package); : It is not clear to me what the elaboration order should be in the case of : nested packages. I would like to assume that for nested packages, the : elaboration is also nested. In the case of generic instantiations, both : spec and body would be elaborated at the point of instantiation. All true. : Unfortunately, the LRM does not seem to make any requirements regarding : elaboration order for nested packages. Not true. : ... I've tried the above source code : with Ada/ED and an Alsys Ada83 compiler and it seems to work OK. : When I use gnat, I get a program error. The Ada95 pragmas used for : controlling elaboration order seem to only apply to library units. That's true in Ada 83 as well. : ... In the : example above, I believe that INSTANCE is a program unit but not a library : unit. Is there some way I can force the elaboration of INSTANCE to occur : immediately? Your problem is not the elaboration of Instance. It is the elaboration of the body of Generic_Package. You are falling afoul of the elaboration check that takes place when you instantiate a generic, which requires that the generic body has already been elaborated. As a general rule, if a compilation unit has a "with" for a generic, it should also have a "pragma Elaborate" for it, if it contains any library-level instantiations of the generic. By the way, you are in good company. Several of the 2.0.1 ACVC tests forget this general rule. : ... : Dennis Reimer -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Cambridge, MA USA