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 bug in aggregate handling


Tested on x86-linux, committed on mainline.

An indexed component of a packed type is typically
rewritten as a shift-and-mask expression, and the original array type is
replaced with the proper modular integer type on which the boolean ops
are legal. This replacement must be made in a way that is compatible with
further expansion of the context of the expression, and therefore assumes
that the indexed component itself will not be reanalyzed (otherwise the
new type of the expression would appear incompatible with that imposed
by the context). As a consequence, after applying the packed array type
to the expression, mark it as analyzed, to prevent spurious type errors
downstream.

Test case:
$ gnatmake try
$ try
--
with text_io; use text_io;
procedure try is
   type t is array (1..512) of boolean;
   pragma pack (t);
   type t2 is array (1..20) of t;
   thing1 : t2 := (others => ( 1|3|5|7|9 => true, others => false));
   procedure check (it : boolean) is
   begin
      if not it then
        put_line ("FAILED");
      end if;
   end;
   yes : boolean;
begin
   yes := thing1 (5)(7);
   check (yes);
   for J in 0 .. 4 loop
      check (thing1 (10) (2*J + 1));
   end loop;
end;

2004-11-18  Ed Schonberg  <schonberg@adacore.com>

	* exp_pakd.adb (Convert_To_PAT_Type): After replacing the original
	type of the object with the packed array type, set the Analyzed flag
	on the object if it is an entity or simple indexed component, to avoid
	spurious type errors.

Attachment: difs.11
Description: Text document


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