* fixed limit checking for qword

This commit is contained in:
peter 2002-10-06 21:02:17 +00:00
parent 865e10d6b0
commit a1b570bc48
2 changed files with 44 additions and 16 deletions

View File

@ -84,6 +84,8 @@ interface
orddefs, false otherwise } orddefs, false otherwise }
function is_in_limit(def_from,def_to : tdef) : boolean; function is_in_limit(def_from,def_to : tdef) : boolean;
function is_in_limit_value(val_from:TConstExprInt;def_from,def_to : tdef) : boolean;
{***************************************************************************** {*****************************************************************************
Array helper functions Array helper functions
*****************************************************************************} *****************************************************************************}
@ -640,10 +642,29 @@ implementation
end; end;
fromqword := torddef(def_from).typ = u64bit; fromqword := torddef(def_from).typ = u64bit;
toqword := torddef(def_to).typ = u64bit; toqword := torddef(def_to).typ = u64bit;
is_in_limit:=((not(fromqword xor toqword) and is_in_limit:=(toqword and is_signed(def_from)) or
(torddef(def_from).low>=torddef(def_to).low) and ((not fromqword) and
(torddef(def_from).high<=torddef(def_to).high)) or (torddef(def_from).low>=torddef(def_to).low) and
(toqword and not is_signed(def_from))); (torddef(def_from).high<=torddef(def_to).high));
end;
function is_in_limit_value(val_from:TConstExprInt;def_from,def_to : tdef) : boolean;
begin
if (def_from.deftype <> orddef) and
(def_to.deftype <> orddef) then
internalerror(200210062);
if (torddef(def_to).typ = u64bit) then
begin
is_in_limit_value:=((TConstExprUInt(val_from)>=TConstExprUInt(torddef(def_to).low)) and
(TConstExprUInt(val_from)<=TConstExprUInt(torddef(def_to).high)));
end
else
begin;
is_in_limit_value:=((val_from>=torddef(def_to).low) and
(val_from<=torddef(def_to).high));
end;
end; end;
@ -1075,14 +1096,16 @@ implementation
if (def1.deftype=orddef) and (def2.deftype=orddef) then if (def1.deftype=orddef) and (def2.deftype=orddef) then
begin begin
case torddef(def1).typ of case torddef(def1).typ of
u8bit,u16bit,u32bit, u8bit,u16bit,u32bit,u64bit,
s8bit,s16bit,s32bit: s8bit,s16bit,s32bit,s64bit:
b:=((torddef(def1).typ=torddef(def2).typ) and b:=((torddef(def1).typ=torddef(def2).typ) and
(torddef(def1).low=torddef(def2).low) and (torddef(def1).low=torddef(def2).low) and
(torddef(def1).high=torddef(def2).high)); (torddef(def1).high=torddef(def2).high));
uvoid,uchar,uwidechar, uvoid,uchar,uwidechar,
bool8bit,bool16bit,bool32bit: bool8bit,bool16bit,bool32bit:
b:=(torddef(def1).typ=torddef(def2).typ); b:=(torddef(def1).typ=torddef(def2).typ);
else
internalerror(200210061);
end; end;
end end
else else
@ -1981,7 +2004,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.18 2002-10-06 15:08:59 peter Revision 1.19 2002-10-06 21:02:17 peter
* fixed limit checking for qword
Revision 1.18 2002/10/06 15:08:59 peter
* only check for forwarddefs the definitions that really belong to * only check for forwarddefs the definitions that really belong to
the current procsym the current procsym

View File

@ -1433,8 +1433,7 @@ implementation
(tbinarynode(p).left.nodetype=ordconstn) and (tbinarynode(p).left.nodetype=ordconstn) and
is_integer(p.resulttype.def) and is_integer(p.resulttype.def) and
is_integer(def) and is_integer(def) and
(tordconstnode(p.left).value>=torddef(def).low) and is_in_limit_value(tordconstnode(p.left).value,p.resulttype.def,def)
(tordconstnode(p.left).value<=torddef(def).high)
) )
{ to support ansi/long/wide strings in a proper way } { to support ansi/long/wide strings in a proper way }
{ string and string[10] are assumed as equal } { string and string[10] are assumed as equal }
@ -2632,7 +2631,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.104 2002-10-05 15:15:45 peter Revision 1.105 2002-10-06 21:02:17 peter
* fixed limit checking for qword
Revision 1.104 2002/10/05 15:15:45 peter
* Write unknwon compiler proc using Comment and only in Extdebug * Write unknwon compiler proc using Comment and only in Extdebug
Revision 1.103 2002/10/05 12:43:25 carl Revision 1.103 2002/10/05 12:43:25 carl