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