This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Ada] fix bug in aggregate handling
- From: ja2morri at csclub dot uwaterloo dot ca (James A. Morrison)
- To: Arnaud Charlet <charlet at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Ed Schonberg <schonberg at adacore dot com>
- Date: 21 Nov 2004 19:13:15 -0500
- Subject: Re: [Ada] fix bug in aggregate handling
- References: <20041119111102.GB22301@adacore.com>
Arnaud Charlet <charlet@adacore.com> writes:
> 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.
Would one of these spurious type erros be something like:
packed_3.adb:18:14: expected type "System.Unsigned_Types.Packed_Byte"
packed_3.adb:18:14: found type "Standard.Boolean"
> 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;
--
Thanks,
Jim
http://www.student.cs.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim