mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 10:19:17 +02:00
* 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:
parent
be4daa86e4
commit
d45ba6c966
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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
26
tests/webtbs/tw17862.pp
Normal 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.
|
||||
|
Loading…
Reference in New Issue
Block a user