* avoid range check errors when inlining not-nodes (mantis #21029)

git-svn-id: trunk@20046 -
This commit is contained in:
Jonas Maebe 2012-01-10 22:23:25 +00:00
parent ad2aa1ceb3
commit 3b8ae840c1
3 changed files with 26 additions and 2 deletions

1
.gitattributes vendored
View File

@ -12112,6 +12112,7 @@ tests/webtbs/tw20962.pp svneol=native#text/plain
tests/webtbs/tw20995a.pp svneol=native#text/pascal
tests/webtbs/tw20995b.pp svneol=native#text/pascal
tests/webtbs/tw20998.pp svneol=native#text/pascal
tests/webtbs/tw21029.pp svneol=native#text/plain
tests/webtbs/tw2109.pp svneol=native#text/plain
tests/webtbs/tw2110.pp svneol=native#text/plain
tests/webtbs/tw2128.pp svneol=native#text/plain

View File

@ -1003,10 +1003,21 @@ implementation
else
CGMessage(type_e_mismatch);
end;
if not forinline then
{ not-nodes are not range checked by the code generator -> also
don't range check while inlining; the resultdef is a bit tricky
though: the node's resultdef gets changed in most cases compared
to left, but the not-operation itself is caried out in the code
generator using the size of left
}
if not(forinline) then
t:=cordconstnode.create(v,def,false)
else
t:=create_simplified_ord_const(v,resultdef,true);
begin
{ cut off the value if necessary }
t:=cordconstnode.create(v,left.resultdef,false);
{ now convert to node's resultdef }
inserttypeconv_explicit(t,def);
end;
result:=t;
exit;
end;

12
tests/webtbs/tw21029.pp Normal file
View File

@ -0,0 +1,12 @@
{$r+}
{$inline on}
function F(y : byte) : byte; inline;
begin
f:=byte(not y);
end;
BEGIN
if F(1)<>254 then
halt(1);
END.