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 issue with discriminant with non static bounds


Test on i686-linux, committed on trunk.

If the bounds of the type of the discriminant are not static, the back-end
will treat an object of the type (including an aggregate with all static
components) has having a dynamic size, even if the discriminant and all the
components have in fact a statically computable size.
The following must compile quietly:
--
procedure P is
   type Nat_T is range 0 .. 32;
   function Dyn_Nat_Max return Nat_T is begin return 12; end;
   subtype Dyn_Nat_T is Nat_T     range 0 .. Dyn_Nat_Max;
   subtype Dyn_Pos_T is Dyn_Nat_T range 1 .. Dyn_Nat_T'Last;
   type Array_T is array (Dyn_Pos_T range <>) of Natural;
   type Data_T (Size : Dyn_Nat_T) is record
      Bits : Array_T (1 .. Size);
   end record;
   procedure Process  (Data : Data_T) is begin  null; end;
begin
   Process (Data => (Size => 1, Bits => (1 => 1)));
end;

2006-02-17  Ed Schonberg  <schonberg@adacore.com>

	* freeze.adb (Statically_Discriminated_Components): Return false if
	the bounds of the type of the discriminant are not static expressions.

	* sem_aggr.adb (Check_Static_Discriminated_Subtype): Return false if
	the bounds of the discriminant type are not static.

Attachment: difs.6
Description: Text document


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