* fixed overflow for constant in-expressions involving values >

high(uinttype) on the left side

git-svn-id: trunk@6852 -
This commit is contained in:
Jonas Maebe 2007-03-14 19:42:01 +00:00
parent ac585ea201
commit f63b0ef160

View File

@ -286,8 +286,17 @@ implementation
begin
if (right.nodetype=setconstn) then
begin
t:=cordconstnode.create(byte(tordconstnode(left).value in Tsetconstnode(right).value_set^),
booltype,true);
{ tordconstnode.value is int64 -> signed -> the expression }
{ below will be converted to longint on 32 bit systems due }
{ to the rule above -> will give range check error if }
{ value > high(longint) if we don't take the signedness }
{ into account }
if is_signed(left.resultdef) then
t:=cordconstnode.create(byte(tordconstnode(left).value in Tsetconstnode(right).value_set^),
booltype,true)
else
t:=cordconstnode.create(byte(TConstExprUInt(tordconstnode(left).value) in Tsetconstnode(right).value_set^),
booltype,true);
typecheckpass(t);
result:=t;
exit;