diff --git a/.gitattributes b/.gitattributes index b2aefa2aca..a156737ab3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16415,6 +16415,7 @@ tests/webtbs/tw3433.pp svneol=native#text/plain tests/webtbs/tw34332.pp svneol=native#text/pascal tests/webtbs/tw3435.pp svneol=native#text/plain tests/webtbs/tw34380.pp svneol=native#text/plain +tests/webtbs/tw34385.pp svneol=native#text/plain tests/webtbs/tw3441.pp svneol=native#text/plain tests/webtbs/tw3443.pp svneol=native#text/plain tests/webtbs/tw34438.pp svneol=native#text/pascal diff --git a/compiler/nadd.pas b/compiler/nadd.pas index 9ea4535026..ed559e54fe 100644 --- a/compiler/nadd.pas +++ b/compiler/nadd.pas @@ -377,11 +377,11 @@ implementation function taddnode.simplify(forinline : boolean) : tnode; - function is_range_test(nodel, noder: taddnode; var value: tnode; var cl,cr: Tconstexprint): boolean; + function is_range_test(nodel, noder: taddnode; out value: tnode; var cl,cr: Tconstexprint): boolean; const is_upper_test: array[ltn..gten] of boolean = (true,true,false,false); - inclusive_adjust: array[boolean,ltn..gten] of integer = ((1,0,-1,0), - (-1,0,1,0)); + inclusive_adjust: array[boolean,ltn..gten] of integer = ((-1,0,1,0), + (1,0,-1,0)); var swapl, swapr: Boolean; valuer: tnode; @@ -1056,7 +1056,7 @@ implementation if is_boolean(left.resultdef) and is_boolean(right.resultdef) then begin { transform unsigned comparisons of (v>=x) and (v<=y) - into (v-x)<(y-x) + into (v-x)<=(y-x) } if (nodetype=andn) and (left.nodetype in [ltn,lten,gtn,gten]) and diff --git a/tests/webtbs/tw34385.pp b/tests/webtbs/tw34385.pp new file mode 100644 index 0000000000..35c504e81d --- /dev/null +++ b/tests/webtbs/tw34385.pp @@ -0,0 +1,23 @@ +program rangeTest; +const + w : dword = 123; + n : dword = 48; +begin + if (w<=1) and (w>=10) then + begin + writeln('error 1-10'); + halt(1); + end; + if (w>=1) and (w<=1000) then + writeln('ok') + else + begin + writeln('error 1-1000'); + halt(2); + end; + if (n>44)and(n<48) then + begin + writeln('error 48'); + halt(3); + end; +end.