This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Handle allocators types defined in limited-with packages


This patch adds the missing support to handle entities associated with
types declared in limited-withed packages. The following patch must
execute without errors.

with Ada.Finalization; use Ada.Finalization;
package Pkg_1 is
   type Iface is limited interface;
   procedure X (Self : access Iface) is abstract;
   procedure Y (Self : access Iface) is abstract;
   function Get_Name (Self : access Iface) return String is abstract;

   type Iface_Impl is new Limited_Controlled and Iface with null record;
   procedure X (Self : access Iface_Impl) is null;
   procedure Y (Self : access Iface_Impl) is null;
   function Get_Name (Self : access Iface_Impl) return String;
end;

limited with Pkg_1;
package Pkg_2 is
   type Iface_Access is access all Pkg_1.Iface'Class;
end;

with Pkg_2;
package Pkg_3 is
   function Iface_Func return Pkg_2.Iface_Access;
end;

with Pkg_2;
with Pkg_1;
package body Pkg_3 is
   C_Class : Pkg_2.Iface_Access := new Pkg_1.Iface_Impl;

   function Iface_Func return Pkg_2.Iface_Access is
   begin
      return C_Class;
   end;
end;

with Ada.Text_IO;
package body Pkg_1 is
   function Get_Name (Self : access Iface_Impl) return String is
   begin
      Ada.Text_IO.Put_Line ("CALLED");
      return "TEST PASSED";
   end;
end;

with Ada.Text_IO;
with Pkg_1;
with Pkg_3;
procedure Small_Test is
   X : String := Pkg_3.Iface_Func.Get_Name;
begin
   Ada.Text_IO.Put_Line ("PASSED");
end;

Command: gnatmake -gnat05 Small_Test; ./small_test
Output:
CALLED
PASSED

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-06-23  Javier Miranda  <miranda@adacore.com>

	* exp_ch4.adb (Displace_Allocator_Pointer, Expand_N_Allocator): Handle
	designated types referencing entities from the limited view.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]