|
@@ -1013,6 +1013,14 @@ implementation
|
|
change : boolean;
|
|
change : boolean;
|
|
{$endif}
|
|
{$endif}
|
|
|
|
|
|
|
|
+ function maybe_cast_ordconst(var n: tnode; adef: tdef): boolean;
|
|
|
|
+ begin
|
|
|
|
+ result:=(tordconstnode(n).value>=torddef(adef).low) and
|
|
|
|
+ (tordconstnode(n).value<=torddef(adef).high);
|
|
|
|
+ if result then
|
|
|
|
+ inserttypeconv(n,adef);
|
|
|
|
+ end;
|
|
|
|
+
|
|
begin
|
|
begin
|
|
result:=nil;
|
|
result:=nil;
|
|
rlow:=0;
|
|
rlow:=0;
|
|
@@ -1420,6 +1428,18 @@ implementation
|
|
inserttypeconv(right,nd);
|
|
inserttypeconv(right,nd);
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
|
|
+ { don't extend (sign-mismatched) comparisons if either side is a constant
|
|
|
|
+ whose value is within range of opposite side }
|
|
|
|
+ else if is_integer(ld) and is_integer(rd) and
|
|
|
|
+ (nodetype in [equaln,unequaln,gtn,gten,ltn,lten]) and
|
|
|
|
+ (is_signed(ld)<>is_signed(rd)) and
|
|
|
|
+ (
|
|
|
|
+ ((lt=ordconstn) and maybe_cast_ordconst(left,rd)) or
|
|
|
|
+ ((rt=ordconstn) and maybe_cast_ordconst(right,ld))
|
|
|
|
+ ) then
|
|
|
|
+ begin
|
|
|
|
+ { done here }
|
|
|
|
+ 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
|
|
begin
|
|
begin
|