* only ordinals and enums can be bitpacked -> don't give an error when

e.g. passing a 3-byte record in a bitpacked array as var-parameter
    (mantis #17862)

git-svn-id: trunk@16317 -
This commit is contained in:
Jonas Maebe 2010-11-08 21:23:55 +00:00
parent be4daa86e4
commit d45ba6c966
3 changed files with 33 additions and 0 deletions

1
.gitattributes vendored
View File

@ -10735,6 +10735,7 @@ tests/webtbs/tw17715.pp svneol=native#text/plain
tests/webtbs/tw1779.pp svneol=native#text/plain
tests/webtbs/tw1780.pp svneol=native#text/plain
tests/webtbs/tw17836.pp svneol=native#text/plain
tests/webtbs/tw17862.pp svneol=native#text/plain
tests/webtbs/tw1792.pp svneol=native#text/plain
tests/webtbs/tw1792a.pp svneol=native#text/plain
tests/webtbs/tw1798.pp svneol=native#text/plain

View File

@ -1151,10 +1151,16 @@ implementation
vecn:
result:=
is_packed_array(tvecnode(n).left.resultdef) and
{ only orddefs and enumdefs are actually bitpacked. Don't consider
e.g. an access to a 3-byte record as "bitpacked", since it
isn't }
(tvecnode(n).left.resultdef.typ in [orddef,enumdef]) and
not(tarraydef(tvecnode(n).left.resultdef).elepackedbitsize in [8,16,32,64]);
subscriptn:
result:=
is_packed_record_or_object(tsubscriptnode(n).left.resultdef) and
{ see above }
(tsubscriptnode(n).vs.vardef.typ in [orddef,enumdef]) and
(not(tsubscriptnode(n).vs.vardef.packedbitsize in [8,16,32,64]) or
(tsubscriptnode(n).vs.fieldoffset mod 8 <> 0));
else

26
tests/webtbs/tw17862.pp Normal file
View File

@ -0,0 +1,26 @@
{$mode objfpc}
type
TField = record
a,b,c: byte;
end;
tarray = bitpacked array[0..3] of tfield;
procedure test(var a: tfield);
begin
if a.a<>3 then
halt(1);
if a.b<>4 then
halt(2);
if a.c<>5 then
halt(3);
end;
var
a: tarray;
begin
a[1].a:=3;
a[1].b:=4;
a[1].c:=5;
test(a[1]);
end.