* refactored the pass_typecheck code for and/or/xor/comparisons, so that the logic is simpler, but still yields exactly the same result

git-svn-id: trunk@26823 -
This commit is contained in:
nickysn 2014-02-21 14:55:00 +00:00
parent cc88c609c8
commit 83dd2aed4a

View File

@ -1392,36 +1392,24 @@ implementation
((nodetype in [orn,xorn,equaln,unequaln,gtn,gten,ltn,lten]) and ((nodetype in [orn,xorn,equaln,unequaln,gtn,gten,ltn,lten]) and
(is_signed(ld)=is_signed(rd)))) then (is_signed(ld)=is_signed(rd)))) then
begin begin
if (rd.size>ld.size) or if (rd.size=ld.size) and
{ Delphi-compatible: prefer unsigned type for "and" with equal size } (is_signed(ld) or is_signed(rd)) then
((rd.size=ld.size) and
not is_signed(rd)) then
begin begin
if (rd.size=ld.size) and { Delphi-compatible: prefer unsigned type for "and" with equal size }
is_signed(ld) then if not is_signed(rd) then
inserttypeconv_internal(left,rd) inserttypeconv_internal(left,rd)
else else
begin inserttypeconv_internal(right,ld);
{ not to left right.resultdef, because that may
cause a range error if left and right's def don't
completely overlap }
nd:=get_common_intdef(torddef(ld),torddef(rd),true);
inserttypeconv(left,nd);
inserttypeconv(right,nd);
end;
end end
else else
begin begin
if (rd.size=ld.size) and { not to left right.resultdef, because that may
is_signed(rd) then cause a range error if left and right's def don't
inserttypeconv_internal(right,ld) completely overlap }
else nd:=get_common_intdef(torddef(ld),torddef(rd),true);
begin inserttypeconv(left,nd);
nd:=get_common_intdef(torddef(ld),torddef(rd),true); inserttypeconv(right,nd);
inserttypeconv(left,nd); end;
inserttypeconv(right,nd);
end;
end
end end
{ is there a signed 64 bit type ? } { is there a signed 64 bit type ? }
else if ((torddef(rd).ordtype=s64bit) or (torddef(ld).ordtype=s64bit)) then else if ((torddef(rd).ordtype=s64bit) or (torddef(ld).ordtype=s64bit)) then