* fixed check for bitpacked accesses (mantis #24007)

git-svn-id: trunk@23705 -
This commit is contained in:
Jonas Maebe 2013-03-07 15:44:41 +00:00
parent eeae77bfc2
commit 3cde2b2d84
3 changed files with 24 additions and 1 deletions

1
.gitattributes vendored
View File

@ -13239,6 +13239,7 @@ tests/webtbs/tw2382.pp svneol=native#text/plain
tests/webtbs/tw2388.pp svneol=native#text/plain
tests/webtbs/tw23962.pp svneol=native#text/plain
tests/webtbs/tw2397.pp svneol=native#text/plain
tests/webtbs/tw24007.pp svneol=native#text/plain
tests/webtbs/tw2409.pp svneol=native#text/plain
tests/webtbs/tw2421.pp svneol=native#text/plain
tests/webtbs/tw2423.pp svneol=native#text/plain

View File

@ -1029,7 +1029,8 @@ implementation
{ 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
(tvecnode(n).left.resultdef.typ = arraydef) and
(tarraydef(tvecnode(n).left.resultdef).elementdef.typ in [orddef,enumdef]) and
not(tarraydef(tvecnode(n).left.resultdef).elepackedbitsize in [8,16,32,64]);
subscriptn:
result:=

21
tests/webtbs/tw24007.pp Normal file
View File

@ -0,0 +1,21 @@
var
str: bitpacked array [1..6] of 'a'..'z';
i: integer;
ch: char;
error: boolean;
begin
error := false;
for i := 1 to 6 do str[i] := chr(ord('a')+i-1);
for i := 1 to 6 do begin
write('str[i] = ''', str[i], '''; ord(str[2]) = ',ord(str[i]));
ch:=str[i]; {if we had used directly str[i] in the expression below, the correct value would have been read}
if ch <> chr(ord(str[i])) then
begin
write(' ==> Bug: chr(',ord(ch),') read, excpected chr(',ord('a')+i-1,')');
error:=true;
end;
writeln;
end;
halt(ord(error));
end.