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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Formal Subprogram Access Date: Fri, 9 Feb 2018 21:03:29 -0600 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Sat, 10 Feb 2018 03:03:30 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="15817"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:50356 Date: 2018-02-09T21:03:29-06:00 List-Id: "Jeffrey R. Carter" wrote in message news:p5l6bd$ete$1@dont-email.me... > Suppose I have something like > > procedure Fpa_Proc (P : not null access procedure) is > -- Empty > begin -- Fpa_Proc > null; > end Fpa_Proc; > > generic -- Fpa_Gen > with procedure P; > procedure Fpa_Gen; > > with Fpa_Proc; > > procedure Fpa_Gen is > -- Empty > begin -- Fpa_Gen > Fpa_Proc (P => P'Access); > end Fpa_Gen; > > (FPA for Formal Procedure Access) > > FSF GNAT 7.2.0 rejects Fpa_Gen with the error > > fpa_gen.adb:6:19: not subtype conformant with declaration at > fpa_proc.adb:1 > fpa_gen.adb:6:19: formal subprograms not allowed > > which I think is correct. I can change it to have a wrapper procedure: Why do you think this is correct? I can't read 3.10.2(32/5) in a way which would prevent using a formal subprogram in this way (assuming that the profile matches, which is does trivially in this case). Indeed, there is specifically an exception allowing "an anonymous access type of an access parameter." It's possible there is some rule somewhere else that I've forgotten. > with Fpa_Proc; > > procedure Fpa_Gen is > procedure New_P is > -- Empty > begin -- New_P > P; > end New_P; > begin -- Fpa_Gen > Fpa_Proc (P => New_P'Access); > end Fpa_Gen; > > which compiles fine. The fact this works makes it rather silly to not allow P directly. > But to my surprise, I can also rename P: > > with Fpa_Proc; > > procedure Fpa_Gen is > procedure New_P renames P; > begin -- Fpa_Gen > Fpa_Proc (P => New_P'Access); > end Fpa_Gen; > > and this also compiles. I would think that if you can't take 'Access of a > generic formal subprogram, then you shouldn't be able to take 'Access of a > renaming of a generic formal subprogram. So I'm wondering if this last > form is legal. My 60 second opinion is that all three should be legal. But if that's wrong for some subtle reason that I've forgotten, then surely the renames is illegal too. (3.10.2(32/5) uses the term "denoted" to ensure that renames are ignored for the purposes of enforcing the rule.) I'd definitely report a bug to the vendor. Randy.