From: Simon Wright <simon@pushface.org>
Subject: Re: GNAT CE 2020 : error when using anon access to subprogram inside protected !?
Date: Tue, 02 Jun 2020 13:04:05 +0100
Date: 2020-06-02T13:04:05+01:00 [thread overview]
Message-ID: <lyzh9lr7wq.fsf@pushface.org> (raw)
In-Reply-To: 73389630-ef9f-4a9a-918e-0ffc89f62e6c@googlegroups.com
Jérôme Haguet <j.haguet@cadwin.com> writes:
> When I start testing existing code with GNAT CE 2020, I faced a
> compilation error when using anonymous access to subprogram inside
> protected body.
> pb20200602.adb:27:18: subprogram "Do_On_Item" has wrong convention
> pb20200602.adb:27:18: does not match access to subprogram declared at line 7
>
>
> package Pb20200602 is
> protected Tokens is
> procedure Call_Walker;
> end;
> end;
>
> -- ---------------------------------------------------------------------
> with Ada.Text_Io;
> package body Pb20200602 is
>
> protected body Tokens is
>
> procedure Walker
> (On_Item : not null access procedure (Name : String);
> Success : out Boolean
> )
> is
> begin
> On_Item.all ("John Doe");
> On_Item.all ("Jane Doe");
> Success := True;
> end;
>
> procedure Call_Walker
> is
> procedure Do_On_Item (Name : String)
> is
> begin
> null;
> end;
> Success : Boolean := False;
> begin
> Walker (Do_On_Item'Access,
> Success);
> if Success then
> Ada.Text_Io.Put_Line ("Success!");
> end if;
> end;
>
> end;
>
> end;
I'm amazed that you can declare Walker inside the PO!
CE 2020 will compile this without complaint if you move Walker outside
the PO.
next prev parent reply other threads:[~2020-06-02 12:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 9:46 GNAT CE 2020 : error when using anon access to subprogram inside protected !? Jérôme Haguet
2020-06-02 12:04 ` Simon Wright [this message]
2020-06-03 6:36 ` Simon Wright
2020-06-03 9:54 ` J-P. Rosen
2020-06-02 13:51 ` J-P. Rosen
2020-06-02 14:37 ` Simon Wright
2020-06-02 14:55 ` Dmitry A. Kazakov
2020-06-02 18:02 ` AdaMagica
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox