Selaa lähdekoodia

* fixed tcasenode.simplify() in case we have to pass via a "less" branch of
of a tcaselabel that also has a valid "greater" branch to arrive at the
correct entry (mantis #30522)

git-svn-id: trunk@34379 -

Jonas Maebe 9 vuotta sitten
vanhempi
commit
3669419bb3
3 muutettua tiedostoa jossa 28 lisäystä ja 3 poistoa
  1. 1 0
      .gitattributes
  2. 1 3
      compiler/nset.pas
  3. 26 0
      tests/webtbs/tw30522.pp

+ 1 - 0
.gitattributes

@@ -15207,6 +15207,7 @@ tests/webtbs/tw30431.pp svneol=native#text/plain
 tests/webtbs/tw30443.pp svneol=native#text/plain
 tests/webtbs/tw3045.pp svneol=native#text/plain
 tests/webtbs/tw3048.pp svneol=native#text/plain
+tests/webtbs/tw30522.pp svneol=native#text/plain
 tests/webtbs/tw3063.pp svneol=native#text/plain
 tests/webtbs/tw3064.pp svneol=native#text/plain
 tests/webtbs/tw3073.pp svneol=native#text/plain

+ 1 - 3
compiler/nset.pas

@@ -873,14 +873,12 @@ implementation
     function tcasenode.simplify(forinline:boolean):tnode;
       var
         tmp: pcaselabel;
-        walkup: boolean;
       begin
         result:=nil;
         if left.nodetype=ordconstn then
           begin
             tmp:=labels;
             { check all case labels until we find one that fits }
-            walkup:=assigned(tmp^.greater);
             while assigned(tmp) do
               begin
                 if (tmp^._low<=tordconstnode(left).value) and
@@ -895,7 +893,7 @@ implementation
                     exit;
                   end;
 
-                if walkup then
+                if tmp^._high<tordconstnode(left).value then
                   tmp:=tmp^.greater
                 else
                   tmp:=tmp^.less;

+ 26 - 0
tests/webtbs/tw30522.pp

@@ -0,0 +1,26 @@
+
+type
+  E = ( a, b, c );
+
+begin
+  case b of
+    a: begin
+         write( 'a' );
+         halt(1);
+       end;
+    c: begin
+         write( 'c' );
+         halt(2);
+       end;
+    b:
+      begin
+        write( 'b' );
+        halt(0);
+      end;
+    else
+      begin
+        write( '?' );
+        halt(3);
+      end
+  end;
+end.