comp.lang.ada
 help / color / mirror / Atom feed
* GNAT CE 2020 : error when using anon access to subprogram inside protected !?
@ 2020-06-02  9:46 Jérôme Haguet
  2020-06-02 12:04 ` Simon Wright
  2020-06-02 13:51 ` J-P. Rosen
  0 siblings, 2 replies; 8+ messages in thread
From: Jérôme Haguet @ 2020-06-02  9:46 UTC (permalink / raw)


Hello 

When I start testing existing code with GNAT CE 2020, I faced a compilation error when using anonymous access to subprogram inside protected body.

Maybe somebody can provide an explanation ...

Hereafter you will find the compiler message and (simplified) code that illustrates my problem 


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;




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-06-03  9:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox