* correctly change the signdness information of tordconstnodes that are

simplified via typeconvnode (corrects resultdef of "qword(1) shl 33",
    mantis #22133)
  * simplify shl/shr nodes after their resultdef has been set, so the
    resultdef used during simplify is set (fixes same expression as above
    when it is calculated by an inline function)

git-svn-id: trunk@21394 -
This commit is contained in:
Jonas Maebe 2012-05-26 13:31:23 +00:00
parent baa8fa39a8
commit 9e0184884e
4 changed files with 41 additions and 4 deletions

1
.gitattributes vendored
View File

@ -12615,6 +12615,7 @@ tests/webtbs/tw2196.pp svneol=native#text/plain
tests/webtbs/tw2197.pp svneol=native#text/plain
tests/webtbs/tw2198.pp svneol=native#text/plain
tests/webtbs/tw2210.pp svneol=native#text/plain
tests/webtbs/tw22133.pp svneol=native#text/plain
tests/webtbs/tw2214.pp svneol=native#text/plain
tests/webtbs/tw2220.pp svneol=native#text/plain
tests/webtbs/tw2226.pp svneol=native#text/plain

View File

@ -2699,6 +2699,10 @@ implementation
testrange(resultdef,tordconstnode(left).value,(nf_explicit in flags),false);
left.resultdef:=resultdef;
tordconstnode(left).typedef:=resultdef;
if is_signed(resultdef) then
tordconstnode(left).value.signed:=true
else
tordconstnode(left).value.signed:=false;
result:=left;
left:=nil;
exit;

View File

@ -590,10 +590,6 @@ implementation
exit;
end;
result:=simplify(false);
if assigned(result) then
exit;
{$ifdef cpunodefaultint}
{ for small cpus we use the smallest common type }
if (left.resultdef.typ=orddef) and (right.resultdef.typ=orddef) then
@ -632,6 +628,10 @@ implementation
{$endif cpunodefaultint}
resultdef:=left.resultdef;
result:=simplify(false);
if assigned(result) then
exit;
end;

32
tests/webtbs/tw22133.pp Normal file
View File

@ -0,0 +1,32 @@
program tw22133;
{$mode objfpc}{$H+}
type
uint64 = qword;
var
T64:UInt64;
//force checking constants in compile-time
{$RANGECHECKS ON}
{$inline on}
function testshift(a:uint64; b: byte): uint64; inline;
begin
result:=a shl b;
end;
begin
T64:=UInt64(1 shl 63);
if T64<>uint64(high(int64)+1) then
halt(1);
T64:=UInt64(1) shl 63;
if T64<>uint64(high(int64)+1) then
halt(2);
T64:=testshift(1,63);
if T64<>uint64(high(int64)+1) then
halt(3);
end.