* do not apply range test optimization if the variable is a string being compared against a char constants, resolves

git-svn-id: trunk@46453 -
This commit is contained in:
florian 2020-08-15 18:29:26 +00:00
parent 7e8b9122dd
commit 18b8b9c566
3 changed files with 10 additions and 2 deletions

1
.gitattributes vendored
View File

@ -16559,6 +16559,7 @@ tests/webtbf/tw3740.pp svneol=native#text/plain
tests/webtbf/tw37460.pp svneol=native#text/pascal
tests/webtbf/tw37462.pp svneol=native#text/pascal
tests/webtbf/tw37475.pp svneol=native#text/pascal
tests/webtbf/tw37476.pp svneol=native#text/pascal
tests/webtbf/tw3790.pp svneol=native#text/plain
tests/webtbf/tw3812.pp svneol=native#text/plain
tests/webtbf/tw3930a.pp svneol=native#text/plain

View File

@ -1326,7 +1326,9 @@ implementation
(right.nodetype in [ltn,lten,gtn,gten]) and
(not might_have_sideeffects(left)) and
(not might_have_sideeffects(right)) and
is_range_test(taddnode(left),taddnode(right),vl,cl,cr) then
is_range_test(taddnode(left),taddnode(right),vl,cl,cr) and
{ avoid optimization being applied to (<string. var > charconst1) and (<string. var < charconst2) }
(vl.resultdef.typ in [orddef,enumdef]) then
begin
hdef:=get_unsigned_inttype(vl.resultdef);
vl:=ctypeconvnode.create_internal(vl.getcopy,hdef);
@ -3000,7 +3002,7 @@ implementation
end;
end;
if not codegenerror and
if (errorcount=0) and
not assigned(result) then
result:=simplify(false);
end;

5
tests/webtbf/tw37476.pp Normal file
View File

@ -0,0 +1,5 @@
{ %fail }
var a : string = (a >= 'A') and (a <= 'F');
begin
end.