Browse Source

* when deciding about the case code generation in case of size optimization, the number of labels is relevant, not the covered range, resolves #34818

git-svn-id: trunk@40851 -
florian 6 năm trước cách đây
mục cha
commit
644c47e121
3 tập tin đã thay đổi với 27 bổ sung1 xóa
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/ncgset.pas
  3. 25 0
      tests/webtbs/tw34818.pp

+ 1 - 0
.gitattributes

@@ -16474,6 +16474,7 @@ tests/webtbs/tw3474.pp svneol=native#text/plain
 tests/webtbs/tw3477.pp svneol=native#text/plain
 tests/webtbs/tw3478.pp svneol=native#text/plain
 tests/webtbs/tw3479.pp svneol=native#text/plain
+tests/webtbs/tw34818.pp svneol=native#text/pascal
 tests/webtbs/tw34848.pp svneol=native#text/pascal
 tests/webtbs/tw3489.pp svneol=native#text/plain
 tests/webtbs/tw3490.pp svneol=native#text/plain

+ 1 - 1
compiler/ncgset.pas

@@ -1259,7 +1259,7 @@ implementation
                           (max_label<=high(aint)) and
                           not((labelcnt<=2) or
                               (distv.svalue<0) or
-                              (dist>3*TrueCount)) then
+                              (dist>3*labelcnt)) then
                          begin
                            { if the labels less or more a continuum then }
                            genjumptable(labels,min_label.svalue,max_label.svalue);

+ 25 - 0
tests/webtbs/tw34818.pp

@@ -0,0 +1,25 @@
+{ %OPT=-O1s }
+program Project1;
+
+var CharValue: cardinal;
+begin
+  CharValue:=12;
+  case CharValue of
+   $00000000..$0000007f:begin
+     writeln('ok');
+     halt(0);
+   end;
+   $00000080..$000007ff:begin
+     halt(1);
+   end;
+   $00000800..$0000ffff:begin
+     halt(1);
+   end;
+   $00010000..$0010ffff:begin
+     halt(1);
+   end;
+   $00200000..$03ffffff:begin
+     halt(1);
+   end;
+  end;
+end.