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]

Re: [Ada] fix bug in aggregate handling



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


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