* correctly calc case label distance after r36362, resolves #32115 and #32311

git-svn-id: trunk@37390 -
This commit is contained in:
florian 2017-10-03 20:36:09 +00:00
parent 58454f555a
commit cc44328109
3 changed files with 30 additions and 8 deletions

1
.gitattributes vendored
View File

@ -15788,6 +15788,7 @@ tests/webtbs/tw3207.pp svneol=native#text/plain
tests/webtbs/tw3210.pp svneol=native#text/plain
tests/webtbs/tw32108.pp svneol=native#text/pascal
tests/webtbs/tw32111.pp svneol=native#text/pascal
tests/webtbs/tw32115.pp svneol=native#text/pascal
tests/webtbs/tw32118.pp svneol=native#text/pascal
tests/webtbs/tw3212.pp svneol=native#text/plain
tests/webtbs/tw3214.pp svneol=native#text/plain

View File

@ -1003,7 +1003,7 @@ implementation
var
oldflowcontrol: tflowcontrol;
i : longint;
distv,dist,
dist,distv,
lv,hv,
max_label: tconstexprint;
labelcnt : tcgint;
@ -1081,14 +1081,9 @@ implementation
{ can we omit the range check of the jump table ? }
getrange(left.resultdef,lv,hv);
jumptable_no_range:=(lv=min_label) and (hv=max_label);
{ hack a little bit, because the range can be greater }
{ than the positive range of a aint }
if (min_label<0) and (max_label>0) then
distv:=max_label+min_label
else
distv:=max_label-min_label;
if (distv>=0) then
distv:=max_label-min_label;
if distv>=0 then
dist:=distv.uvalue
else
dist:=-distv.svalue;

26
tests/webtbs/tw32115.pp Normal file
View File

@ -0,0 +1,26 @@
{$mode objfpc}
program Project1;
function CalcSmth(const AValue: Integer): Integer;
begin
case AValue of
-9999999..-1000000: Result := 2;
-999999..-100000: Result := 7;
-99999..-10000: Result := 5;
-9999..-1000: Result := 6;
-999..-100: Result := 3;
-99..-10: Result := 2;
-9..-1: Result := 3;
0..9: Result := 5;
10..99: Result := 2;
100..999: Result := 3;
1000..9999: Result := 1;
10000..99999: Result := 5;
100000..999999: Result := 8;
1000000..9999999: Result := 6;
end;
end;
begin
CalcSmth(0);
end.