* don't insert type conversions in add nodes if both arguments are constant

and if the result does not depend on the types of the arguments (to
    prevent "qwordconst>int64const" being turned into
    "int64(qwordconst)>int64const" and thereby potentially change the outcome)
    (mantis #19622)

git-svn-id: trunk@21395 -
This commit is contained in:
Jonas Maebe 2012-05-26 14:14:59 +00:00
parent 9e0184884e
commit a2426178dc
3 changed files with 44 additions and 0 deletions

1
.gitattributes vendored
View File

@ -12498,6 +12498,7 @@ tests/webtbs/tw19500.pp svneol=native#text/pascal
tests/webtbs/tw19511.pp svneol=native#text/pascal
tests/webtbs/tw19548.pp svneol=native#text/pascal
tests/webtbs/tw19555.pp svneol=native#text/pascal
tests/webtbs/tw19622.pp -text svneol=native#text/plain
tests/webtbs/tw1964.pp svneol=native#text/plain
tests/webtbs/tw19651.pp svneol=native#text/plain
tests/webtbs/tw19700.pp svneol=native#text/plain

View File

@ -1347,6 +1347,16 @@ implementation
if (torddef(rd).ordtype<>scurrency) then
inserttypeconv(right,s64currencytype);
end
{ leave some constant integer expressions alone in case the
resultdef of the integer types doesn't influence the outcome,
because the forced type conversions below can otherwise result
in unexpected results (such as high(qword)<high(int64) returning
true because high(qword) gets converted to int64) }
else if is_integer(ld) and is_integer(rd) and
(lt=ordconstn) and (rt=ordconstn) and
(nodetype in [equaln,unequaln,gtn,gten,ltn,lten]) then
begin
end
{ "and" does't care about the sign of integers }
{ "xor", "or" and compares don't need extension to native int }
{ size either as long as both values are signed or unsigned }

33
tests/webtbs/tw19622.pp Normal file
View File

@ -0,0 +1,33 @@
Var a,b:qword;
c:boolean;
aa,bb:longword;
Begin
a:=qword($FFFFFFFFFFFFFFFF);
b:=9223372036854775807;
c:=a>b;
if not c then
halt(1);
if not(qword($FFFFFFFFFFFFFFFF)>9223372036854775807) then
halt(2);
c:=qword($FFFFFFFFFFFFFFFF)>b;
if not c then
halt(3);
c:=18446744073709551615>=9223372036854775807;
if not c then
halt(4);
aa:=$FFFFFFFF;
bb:=2147483647;
c:=aa>bb;
if not c then
halt(5);
if not ($FFFFFFFF>2147483647) then
halt(6);
c:=$FFFFFFFF>bb;
if not c then
halt(7);
c:=4294967295>=2147483647;
if not c then
halt(8);
End.