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] fix layout issue on limited with


Tested on i686-linux, committed on trunk

When we freeze an access type, we assign a size to it.  That means we
need to determine whether it points to an unconstrained array (meaning
a fat pointer is used) or not.  That test didn't take into account
types from a limited with.  The fix is to replace the test for incomplete
types with a cal lto Underlying_Type, which handles both that case and the
limited with case.

The test case is:

package Args is
   type Integer_Array is array (Integer range <>) of Integer;
   type Hook is access procedure (A : access Integer_Array; Id : Integer);
   Expected_Id : constant Integer := 22;
end;
limited with Args;
package Limited_With_Args is
   procedure Process (A : access Args.Integer_Array; Id : Integer);
end;
with Args;
package body Limited_With_Args is
   procedure Process (A : access Args.Integer_Array; Id : Integer) is
   begin
      if Id /= Args.Expected_Id then
	 raise Program_Error;
      end if;
   end;
end;
with Args;
package With_Args is
   procedure Process (A : access Args.Integer_Array; Id : Integer);
end;
package body With_Args is
   procedure Process (A : access Args.Integer_Array; Id : Integer) is
   begin
      if Id /= Args.Expected_Id then
         raise Program_Error;
      end if;
   end;
end;
with Args; use Args;
with With_Args, Limited_With_Args;
procedure P is
   Some_Args : aliased Integer_Array := (1 .. 1 => 0);
begin
   With_Args.Process (Some_Args'Access, Expected_Id);
   Limited_With_Args.Process (Some_Args'Access, Expected_Id);

   declare
      H : Hook;
   begin
      H := With_Args.Process'Access;
      H.all (Some_Args'Access, Expected_Id);

      H := Limited_With_Args.Process'Access;
      H.all (Some_Args'Access, Expected_Id);
   end;
end;

2007-08-31  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* layout.adb (Layout_Type): Use Underlying_Type to determine whether an
	access type points to an unconstrained array.

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]