Browse Source

* correctly calculate the number of labels of a c boolean in case statemnts, resolves #41025

florian 8 months ago
parent
commit
4d732b44d4
2 changed files with 18 additions and 1 deletions
  1. 5 1
      compiler/nset.pas
  2. 13 0
      tests/webtbs/tw41025.pp

+ 5 - 1
compiler/nset.pas

@@ -1305,7 +1305,11 @@ implementation
       begin
         { Check label type coverage for enumerations and small types }
         getrange(left.resultdef,lv,hv);
-        typcount:=hv-lv;
+        { low/high value of c-style booleans are not suitable for calculating their "type count" }
+        if is_cbool(left.resultdef) then
+          typcount:=1
+        else
+          typcount:=hv-lv;
         if not assigned(elseblock) then
           begin
             { unless cs_check_all_case_coverage is set, only check for enums, booleans and

+ 13 - 0
tests/webtbs/tw41025.pp

@@ -0,0 +1,13 @@
+{ %OPT=-Sew }
+program a;
+uses types;
+
+var b:longbool;
+
+begin
+  b:=false;
+  case b of
+  true: writeln('True');
+  false: writeln('False');
+  end;
+end.