* use the actual ValSInt type from the system unit, instead of ptrsinttype when

handling the code parameter of val()

git-svn-id: trunk@34608 -
This commit is contained in:
nickysn 2016-10-03 21:45:08 +00:00
parent dd12e0afb2
commit e847971477

View File

@ -1450,6 +1450,7 @@ implementation
newstatement : tstatementnode; newstatement : tstatementnode;
newblock : tblocknode; newblock : tblocknode;
tempcode : ttempcreatenode; tempcode : ttempcreatenode;
valsinttype : tdef;
begin begin
{ for easy exiting if something goes wrong } { for easy exiting if something goes wrong }
result := cerrornode.create; result := cerrornode.create;
@ -1474,6 +1475,9 @@ implementation
exit; exit;
end; end;
{ retrieve the ValSInt type }
valsinttype:=search_system_type('VALSINT').typedef;
{ reverse parameters for easier processing } { reverse parameters for easier processing }
left := reverseparameters(tcallparanode(left)); left := reverseparameters(tcallparanode(left));
@ -1517,12 +1521,12 @@ implementation
newblock:=internalstatements(newstatement); newblock:=internalstatements(newstatement);
{ do we need a temp for code? Yes, if no code specified, or if } { do we need a temp for code? Yes, if no code specified, or if }
{ code is not a 32bit parameter (we already checked whether the } { code is not a valsinttype sized parameter (we already checked }
{ the code para, if specified, was an orddef) } { whether the code para, if specified, was an orddef) }
if not assigned(codepara) or if not assigned(codepara) or
(codepara.resultdef.size<>ptrsinttype.size) then (codepara.resultdef.size<>valsinttype.size) then
begin begin
tempcode := ctempcreatenode.create(ptrsinttype,ptrsinttype.size,tt_persistent,false); tempcode := ctempcreatenode.create(valsinttype,valsinttype.size,tt_persistent,false);
addstatement(newstatement,tempcode); addstatement(newstatement,tempcode);
{ set the resultdef of the temp (needed to be able to get } { set the resultdef of the temp (needed to be able to get }
{ the resultdef of the tempref used in the new code para) } { the resultdef of the tempref used in the new code para) }
@ -1539,14 +1543,14 @@ implementation
{ we need its resultdef later on } { we need its resultdef later on }
codepara.get_paratype; codepara.get_paratype;
end end
else if (torddef(codepara.resultdef).ordtype <> torddef(ptrsinttype).ordtype) then else if (torddef(codepara.resultdef).ordtype <> torddef(valsinttype).ordtype) then
{ because code is a var parameter, it must match types exactly } { because code is a var parameter, it must match types exactly }
{ however, since it will return values >= 0, both signed and } { however, since it will return values >= 0, both signed and }
{ and unsigned ints of the same size are fine. Since the formal } { and unsigned ints of the same size are fine. Since the formal }
{ code para type is sinttype, insert a typecoversion to sint for } { code para type is sinttype, insert a typecoversion to sint for }
{ unsigned para's } { unsigned para's }
begin begin
codepara.left := ctypeconvnode.create_internal(codepara.left,ptrsinttype); codepara.left := ctypeconvnode.create_internal(codepara.left,valsinttype);
{ make it explicit, oterwise you may get a nonsense range } { make it explicit, oterwise you may get a nonsense range }
{ check error if the cardinal already contained a value } { check error if the cardinal already contained a value }
{ > $7fffffff } { > $7fffffff }