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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,691503f3d2c9213d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!195.114.231.69.MISMATCH!feeder.news-service.com!club-internet.fr!feedme-small.clubint.net!proxad.net!feeder1-1.proxad.net!cleanfeed2-b.proxad.net!nnrp12-1.free.fr!not-for-mail From: Samuel Tardieu Newsgroups: comp.lang.ada Subject: Re: Question about circular elaboration order error (GNAT). References: <48024d11$0$19786$4d3efbfe@news.sover.net> Date: Sun, 13 Apr 2008 21:43:19 +0200 Message-ID: <87skxppmlk.fsf@willow.rfc1149.net> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:GbqobryplcsJXETUsKk1j+nD5X0= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Leafnode-NNTP-Posting-Host: 2a01:5d8:5138:2f95::3 Organization: Guest of ProXad - France NNTP-Posting-Date: 13 Apr 2008 21:45:01 MEST NNTP-Posting-Host: 88.191.14.223 X-Trace: 1208115901 news-1.free.fr 27275 88.191.14.223:52608 X-Complaints-To: abuse@proxad.net Xref: g2news1.google.com comp.lang.ada:20913 Date: 2008-04-13T21:45:01+02:00 List-Id: >>>>> "Peter" == Peter C Chapin writes: Peter> I don't understand where the circularity is coming from. Isn't Peter> the following elaborate order acceptable: No. pragma Elaborate_All is transitive, and forces the elaboration of Parent body (since Parent.Child has an implicit dependency on Parent) before... Parent body elaboration. Hence the circular elaboration order. But you can fix the situation by providing GNAT with the necessary elaboration information: - put a "pragma Elaborate (Parent.Child)" in Parent body to indicate that Parent elaboration requires Parent.Child to be elaborated; this pragma isn't transitive, so you have to ensure that subprograms of Parent.Child called during the elaboration of Parent do not themselves require that other packages be elaborated first, or add the required pragma; - put a "pragma Elaborate_Body" in Parent.Child spec if you know that this package is likely to be called during the elaboration of other packages; this requires that the body be elaborated just after the spec. Using only the "pragma Elaborate_Body" will not be enough for GNAT, so the "pragma Elaborate" is required. That is because GNAT is overcautious and adds implicit "pragma Elaborate_All" unless you provide explicit "pragma Elaborate". Note that having GNAT be overcautious by default is actually a good thing: I spent three hours two weeks ago debugging a tricky elaboration problem in a software written for an embedded system. The original author incorrectly used "pragma Elaborate". Had he done nothing, GNAT would have warned him about the dangerous situation. I hope this clarifies things. Sam -- Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/