"SizeInt" inside the compiler references the "size of an int" on the Host platform. What we want for writing size information in PPUs for Generics is "ASizeInt" which is the "size of an int" of the target platform. This fixes Mantis #20947.

* pscanner.pas: change SizeInt to ASizeInt for tokenreadsizeint and tokenwritesizeint and change necessary other locations for record- and replaytokenbuffers
+ Added a test in the hope that some test-platforms do cross platform (e.g. win32 => win64) compilation.

git-svn-id: trunk@21651 -
This commit is contained in:
svenbarth 2012-06-19 08:47:30 +00:00
parent a2f0e54dc6
commit e0b41141d2
3 changed files with 44 additions and 20 deletions

1
.gitattributes vendored
View File

@ -12582,6 +12582,7 @@ tests/webtbs/tw20874b.pp svneol=native#text/pascal
tests/webtbs/tw20889.pp svneol=native#text/pascal
tests/webtbs/tw20909.pp svneol=native#text/pascal
tests/webtbs/tw20940.pp svneol=native#text/pascal
tests/webtbs/tw20947.pp svneol=native#text/pascal
tests/webtbs/tw20962.pp svneol=native#text/plain
tests/webtbs/tw20995a.pp svneol=native#text/pascal
tests/webtbs/tw20995b.pp svneol=native#text/pascal

View File

@ -174,16 +174,16 @@ interface
procedure stoprecordtokens;
procedure replaytoken;
procedure startreplaytokens(buf:tdynamicarray; achange_endian : boolean);
{ bit length sizeint is target depend }
procedure tokenwritesizeint(val : sizeint);
{ bit length asizeint is target depend }
procedure tokenwritesizeint(val : asizeint);
procedure tokenwritelongint(val : longint);
procedure tokenwritelongword(val : longword);
procedure tokenwriteword(val : word);
procedure tokenwriteshortint(val : shortint);
procedure tokenwriteset(var b;size : longint);
procedure tokenwriteenum(var b;size : longint);
function tokenreadsizeint : sizeint;
procedure tokenwritesettings(var asettings : tsettings; var size : sizeint);
function tokenreadsizeint : asizeint;
procedure tokenwritesettings(var asettings : tsettings; var size : asizeint);
{ longword/longint are 32 bits on all targets }
{ word/smallint are 16-bits on all targest }
function tokenreadlongword : longword;
@ -197,7 +197,7 @@ interface
procedure tokenreadset(var b;size : longint);
function tokenreadenum(size : longint) : longword;
procedure tokenreadsettings(var asettings : tsettings; expected_size : longint);
procedure tokenreadsettings(var asettings : tsettings; expected_size : asizeint);
procedure readchar;
procedure readstring;
procedure readnumber;
@ -2184,9 +2184,9 @@ In case not, the value returned can be arbitrary.
recordtokenbuf.write(b,1);
end;
procedure tscannerfile.tokenwritesizeint(val : sizeint);
procedure tscannerfile.tokenwritesizeint(val : asizeint);
begin
recordtokenbuf.write(val,sizeof(sizeint));
recordtokenbuf.write(val,sizeof(asizeint));
end;
procedure tscannerfile.tokenwritelongint(val : longint);
@ -2209,11 +2209,11 @@ In case not, the value returned can be arbitrary.
recordtokenbuf.write(val,sizeof(longword));
end;
function tscannerfile.tokenreadsizeint : sizeint;
function tscannerfile.tokenreadsizeint : asizeint;
var
val : sizeint;
val : asizeint;
begin
replaytokenbuf.read(val,sizeof(sizeint));
replaytokenbuf.read(val,sizeof(asizeint));
if tokenbuf_change_endian then
val:=swapendian(val);
result:=val;
@ -2306,7 +2306,7 @@ In case not, the value returned can be arbitrary.
end;
procedure tscannerfile.tokenreadsettings(var asettings : tsettings; expected_size : longint);
procedure tscannerfile.tokenreadsettings(var asettings : tsettings; expected_size : asizeint);
{ This procedure
needs to be changed whenever
@ -2374,7 +2374,7 @@ In case not, the value returned can be arbitrary.
end;
end;
procedure tscannerfile.tokenwritesettings(var asettings : tsettings; var size : sizeint);
procedure tscannerfile.tokenwritesettings(var asettings : tsettings; var size : asizeint);
{ This procedure
needs to be changed whenever
@ -2450,7 +2450,8 @@ In case not, the value returned can be arbitrary.
var
t : ttoken;
s : tspecialgenerictoken;
len,val,msgnb,copy_size : sizeint;
len,msgnb,copy_size : asizeint;
val : longint;
b : byte;
pmsg : pmessagestaterecord;
begin
@ -2482,7 +2483,7 @@ In case not, the value returned can be arbitrary.
pmsg:=current_settings.pmessage;
while assigned(pmsg) do
begin
if msgnb=high(sizeint) then
if msgnb=high(asizeint) then
{ Too many messages }
internalerror(2011090401);
inc(msgnb);
@ -2492,11 +2493,12 @@ In case not, the value returned can be arbitrary.
pmsg:=current_settings.pmessage;
while assigned(pmsg) do
begin
{ What about endianess here? }
{ What about endianess here?}
{ SB: this is handled by tokenreadlongint }
val:=pmsg^.value;
tokenwritesizeint(val);
tokenwritelongint(val);
val:=ord(pmsg^.state);
tokenwritesizeint(val);
tokenwritelongint(val);
pmsg:=pmsg^.next;
end;
last_message:=current_settings.pmessage;
@ -2613,7 +2615,7 @@ In case not, the value returned can be arbitrary.
procedure tscannerfile.replaytoken;
var
wlen,mesgnb,copy_size : sizeint;
wlen,mesgnb,copy_size : asizeint;
specialtoken : tspecialgenerictoken;
i : byte;
pmsg,prevmsg : pmessagestaterecord;
@ -2717,8 +2719,8 @@ In case not, the value returned can be arbitrary.
end
else
prevmsg^.next:=pmsg;
replaytokenbuf.read(pmsg^.value,sizeof(longint));
replaytokenbuf.read(pmsg^.state,sizeof(tmsgstate));
pmsg^.value:=tokenreadlongint;
pmsg^.state:=tmsgstate(tokenreadlongint);
pmsg^.next:=nil;
prevmsg:=pmsg;
end;

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

@ -0,0 +1,21 @@
{ the important part of this test is a cross compilation which a change in the
size of the bitness, e.g. from Win32 to Win64 where the unit "fgl" was
compiled with the 32-to-64-bit cross compiler and this program itself is
compiled with the native 64-bit compiler }
program tw20947;
uses
fgl;
type
TTestList = specialize TFPGList<Byte>;
Var
Test : TTestList;
begin
Test := TTestList.Create;
Test.Add(2);
WriteLn(Test[0]); // This should output 2 to console
Test.Free;
end.