* fixed bug that caused 'c in ['a'..'z']' to fail on the WebAssembly target, when code is compiled with {$packset 1}

This commit is contained in:
Nikolay Nikolov 2024-01-10 02:33:47 +02:00
parent 2c622e2fe6
commit a8b4c0772c
2 changed files with 39 additions and 1 deletions

View File

@ -474,7 +474,12 @@ implementation
{ allocate a register for the result }
location.register := hlcg.getintregister(current_asmdata.CurrAsmList, uopdef);
if right.location.loc=LOC_CONSTANT then
if (right.location.loc=LOC_CONSTANT) and
(opsize < OS_S8) and { = if unsigned }
(((left.resultdef.typ=orddef) and
(torddef(left.resultdef).low >= int64(tsetdef(right.resultdef).setbase))) or
((left.resultdef.typ=enumdef) and
(tenumdef(left.resultdef).min >= aint(tsetdef(right.resultdef).setbase)))) then
begin
{ can it actually occur currently? CEC }
{ yes: "if bytevar in [1,3,5,7,9,11,13,15]" (JM) }

33
tests/test/tset8.pp Normal file
View File

@ -0,0 +1,33 @@
program tset8;
{$packset 1}
procedure CheckIn(C: Char);
begin
if (C < 'a') or (C > 'z') then
begin
Writeln('Error!');
Halt(1);
end;
end;
procedure CheckOut(C: Char);
begin
if (C >= 'a') and (C <= 'z') then
begin
Writeln('Error!');
Halt(1);
end;
end;
var
C: Char;
begin
for C := #0 to #255 do
begin
if C in ['a'..'z'] then
CheckIn(C)
else
CheckOut(C);
end;
end.