* fixed internal error with bitpacked arrays of composite types whose

size is not a power of two

git-svn-id: trunk@7596 -
This commit is contained in:
Jonas Maebe 2007-06-08 09:11:08 +00:00
parent 1ba2224a3e
commit 65e35ac401
3 changed files with 45 additions and 1 deletions

1
.gitattributes vendored
View File

@ -6907,6 +6907,7 @@ tests/test/tparray17.pp svneol=native#text/plain
tests/test/tparray18.pp svneol=native#text/plain
tests/test/tparray19.pp svneol=native#text/plain
tests/test/tparray2.pp svneol=native#text/plain
tests/test/tparray20.pp svneol=native#text/plain
tests/test/tparray3.pp svneol=native#text/plain
tests/test/tparray4.pp svneol=native#text/plain
tests/test/tparray5.pp svneol=native#text/plain

View File

@ -480,8 +480,12 @@ implementation
byteoffs, bitoffs, alignpower: aint;
temp : longint;
begin
{ only orddefs are bitpacked. Even then we only need special code in }
{ case the bitpacked *byte size* is not a power of two, otherwise }
{ everything can be handled using the the regular array code. }
if ((l mod 8) = 0) and
ispowerof2(l div 8,temp) then
(ispowerof2(l div 8,temp) or
not is_ordinal(resultdef)) then
begin
update_reference_reg_mul(reg,l div 8);
exit;

39
tests/test/tparray20.pp Normal file
View File

@ -0,0 +1,39 @@
program FatalError_200608051;
type
String32 = string[ 32];
String80 = string[ 80];
TDS = record
ZZStyleName: packed array[0..24] of String32;
end;
TDSunp = record
ZZStyleName: array[0..24] of String32;
end;
PDS = ^TDS;
var
DV: PDS;
function StyleNameToSongStyleNum (TheSTYName80: String80): longint;
var
a: Integer;
begin
StyleNameToSongStyleNum := 1;
for A := 1 to 24 do
if Pos(DV^.ZZStyleName[a], TheSTYName80) > 0 then
begin
StyleNameToSongStyleNum := A;
exit;
end;
end;
var
i: integer;
begin
new(dv);
for i := 1 to 24 do
tdsunp(dv^).ZZStyleName[i]:='MySong'+chr(i+ord('A'));
if (StyleNameToSongStyleNum('MySongF') <> 5) then
halt(1);
end.