From 644c47e1213118690d78d593a1c217335215fb1b Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 13 Jan 2019 10:32:00 +0000 Subject: [PATCH] * 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 - --- .gitattributes | 1 + compiler/ncgset.pas | 2 +- tests/webtbs/tw34818.pp | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw34818.pp diff --git a/.gitattributes b/.gitattributes index 2b1519865f..40b9cce81f 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/ncgset.pas b/compiler/ncgset.pas index 517a1f4549..f1a5bf4dd5 100644 --- a/compiler/ncgset.pas +++ b/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); diff --git a/tests/webtbs/tw34818.pp b/tests/webtbs/tw34818.pp new file mode 100644 index 0000000000..9315f7bfa0 --- /dev/null +++ b/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.