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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1ebf2068074538a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-28 03:39:08 PST Sender: sjw@galadriel.frlngtn.gecm.com Newsgroups: comp.lang.ada Subject: Re: Legality: formal packages with controlled types References: From: Simon Wright Date: 28 Nov 2001 11:29:59 +0000 Message-ID: Organization: Alenia Marconi Systems, ISD, Farlington X-Newsreader: Gnus v5.5/Emacs 20.3 NNTP-Posting-Host: galadriel.frlngtn.gecm.com X-Trace: 28 Nov 2001 11:27:08 GMT, galadriel.frlngtn.gecm.com Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!btnet-peer1!btnet-feed3!btnet!newreader.ukcore.bt.net!pull.gecm.com!galadriel.frlngtn.gecm.com Xref: archiver1.google.com comp.lang.ada:17095 Date: 2001-11-28T11:29:59+00:00 List-Id: Simon Wright writes: > The code below fails on OA 7.2 with > > bug.ada: Error: line 21 col 42 LRM:3.9.1(3), The accessibility level > of a record extension shall not exceed that of its parent; this > also applies in a generic instantiation (In instance of generic > base at bug.ada: line 7 col 7) > > and similar code fails similarly on OA 7.2.1 and AdaMULTI v3.1 I'm > told. Presumably they all share a front end. > > The code compiles OK if Base.Container isn't derived from Controlled. > > Is it really the case that it's legal to instantiate a generic package > with a package that contains a controlled type but illegal to > instantiate a generic subprogram? > > ======================================================== > with ada.finalization; > generic > type item is private; > package base is > type container is tagged private; > private > type container is new ada.finalization.controlled with record > the_item : item; > end record; > end base; > > with base; > generic > type item is private; > with package New_Base is new base (item); -- <==== ok > package Generic_package is end Generic_package; > > with base; > generic > type item is private; > with package new_base is new base (item); -- <==== failure > procedure Generic_Procedure; > > procedure generic_procedure is > begin > null; > end generic_procedure; I'm informed by ACT that this code is legal and that the compilers that reject it (which, BTW, include Apex) are wrong to do so.