diff --git a/.gitattributes b/.gitattributes index d722475c1a..b3bc4fa43e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/compiler/nmat.pas b/compiler/nmat.pas index 90258ac7af..2286a12598 100644 --- a/compiler/nmat.pas +++ b/compiler/nmat.pas @@ -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; diff --git a/tests/webtbs/tw21029.pp b/tests/webtbs/tw21029.pp new file mode 100644 index 0000000000..9d10028d76 --- /dev/null +++ b/tests/webtbs/tw21029.pp @@ -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.