* fixed packed arrays of enums in case of packenum 2/4

git-svn-id: trunk@4674 -
This commit is contained in:
Jonas Maebe 2006-09-21 14:46:32 +00:00
parent 56299d584f
commit cc6a91a9bc
3 changed files with 37 additions and 5 deletions

1
.gitattributes vendored
View File

@ -6177,6 +6177,7 @@ tests/test/tpara2.pp svneol=native#text/plain
tests/test/tparray1.pp svneol=native#text/plain tests/test/tparray1.pp svneol=native#text/plain
tests/test/tparray10.pp svneol=native#text/plain tests/test/tparray10.pp svneol=native#text/plain
tests/test/tparray11.pp svneol=native#text/plain tests/test/tparray11.pp svneol=native#text/plain
tests/test/tparray12.pp svneol=native#text/plain
tests/test/tparray2.pp svneol=native#text/plain tests/test/tparray2.pp svneol=native#text/plain
tests/test/tparray3.pp svneol=native#text/plain tests/test/tparray3.pp svneol=native#text/plain
tests/test/tparray4.pp svneol=native#text/plain tests/test/tparray4.pp svneol=native#text/plain

View File

@ -165,6 +165,8 @@ implementation
*****************************************************************************} *****************************************************************************}
procedure tcgaddrnode.pass_2; procedure tcgaddrnode.pass_2;
var
tmpref: treference;
begin begin
secondpass(left); secondpass(left);
@ -477,7 +479,8 @@ implementation
byteoffs, bitoffs, alignpower: aint; byteoffs, bitoffs, alignpower: aint;
temp : longint; temp : longint;
begin begin
if (l mod 8) = 0 then if ((l mod 8) = 0) and
ispowerof2(l div 8,temp) then
begin begin
update_reference_reg_mul(reg,l div 8); update_reference_reg_mul(reg,l div 8);
exit; exit;
@ -692,7 +695,8 @@ implementation
if (left.resulttype.def.deftype=arraydef) and if (left.resulttype.def.deftype=arraydef) and
not(is_dynamic_array(left.resulttype.def)) and not(is_dynamic_array(left.resulttype.def)) and
(not(is_packed_array(left.resulttype.def)) or (not(is_packed_array(left.resulttype.def)) or
(mulsize mod 8 = 0)) then ((mulsize mod 8 = 0) and
ispowerof2(mulsize div 8,temp))) then
dec(location.reference.offset,bytemulsize*tarraydef(left.resulttype.def).lowrange); dec(location.reference.offset,bytemulsize*tarraydef(left.resulttype.def).lowrange);
if right.nodetype=ordconstn then if right.nodetype=ordconstn then
@ -763,9 +767,13 @@ implementation
end; end;
end; end;
if not(is_packed_array(left.resulttype.def)) or if not(is_packed_array(left.resulttype.def)) or
(mulsize mod 8 = 0) then ((mulsize mod 8 = 0) and
inc(location.reference.offset, ispowerof2(mulsize div 8,temp)) then
bytemulsize*tordconstnode(right).value) begin
inc(location.reference.offset,
bytemulsize*tordconstnode(right).value);
newsize:=int_cgsize(bytemulsize);
end
else else
begin begin
subsetref.ref := location.reference; subsetref.ref := location.reference;

23
tests/test/tparray12.pp Normal file
View File

@ -0,0 +1,23 @@
{$packenum 2}
type
tenum = (ea,eb,ec,ed,ee,ef:=255);
tb = array[1..16] of byte;
const
res: array[1..6] of byte = (0,1,2,3,4,255);
var
a: bitpacked array[1..16] of tenum;
i: longint;
begin
writeln(sizeof(a));
a[1]:=ea;
a[2]:=eb;
a[3]:=ec;
a[6]:=ef;
a[5]:=ee;
a[4]:=ed;
for i := 1 to 6 do
begin writeln(tb(a)[i]);
if (tb(a)[i] <> res[i]) then
halt(1); end;
end.