Browse Source

* fix #35841 also for break and continue

git-svn-id: trunk@47070 -
florian 4 years ago
parent
commit
c2c7c23f21
2 changed files with 44 additions and 8 deletions
  1. 6 6
      compiler/x86_64/nx64flw.pas
  2. 38 2
      tests/webtbs/tw35841.pp

+ 6 - 6
compiler/x86_64/nx64flw.pas

@@ -324,8 +324,8 @@ procedure tx64tryfinallynode.pass_generate_code;
     { i32913 - if the try..finally block is also inside a try..finally or
       try..except block, make a note of any Exit calls so all necessary labels
       are generated. [Kit] }
-    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
-      Include(oldflowcontrol, fc_exit);
+    if ((flowcontrol*[fc_exit,fc_break,fc_continue])<>[]) and (fc_inflowcontrol in oldflowcontrol) then
+      oldflowcontrol:=oldflowcontrol+(flowcontrol*[fc_exit,fc_break,fc_continue]);
 
     flowcontrol:=[fc_inflowcontrol];
     { generate finally code as a separate procedure }
@@ -440,8 +440,8 @@ procedure tx64tryexceptnode.pass_generate_code;
     { i32913 - if the try..finally block is also inside a try..finally or
       try..except block, make a note of any Exit calls so all necessary labels
       are generated. [Kit] }
-    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
-      Include(oldflowcontrol, fc_exit);
+    if ((flowcontrol*[fc_exit,fc_break,fc_continue])<>[]) and (fc_inflowcontrol in oldflowcontrol) then
+      oldflowcontrol:=oldflowcontrol+(flowcontrol*[fc_exit,fc_break,fc_continue]);
 
     flowcontrol:=[fc_inflowcontrol];
     { on statements }
@@ -536,8 +536,8 @@ errorexit:
     { i32913 - if the try..finally block is also inside a try..finally or
       try..except block, make a note of any Exit calls so all necessary labels
       are generated. [Kit] }
-    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
-      Include(oldflowcontrol, fc_exit);
+    if ((flowcontrol*[fc_exit,fc_break,fc_continue])<>[]) and (fc_inflowcontrol in oldflowcontrol) then
+      oldflowcontrol:=oldflowcontrol+(flowcontrol*[fc_exit,fc_break,fc_continue]);
 
     { restore the control flow labels }
     current_procinfo.CurrExitLabel:=oldCurrExitLabel;

+ 38 - 2
tests/webtbs/tw35841.pp

@@ -1,9 +1,9 @@
 { %norun }
 {$mode objfpc}
-procedure p;
+procedure p1;
   begin
     try
-      writeln
+      writeln;
     except
       try
         writeln;
@@ -14,5 +14,41 @@ procedure p;
     end;
   end;
 
+
+procedure p2;
+  var
+    i : longint;
+  begin
+    for i:=1 to 10 do
+      try
+        writeln;
+      except
+        try
+          writeln;
+          break;
+        finally
+          writeln;
+        end;
+      end;
+  end;
+
+procedure p3;
+  var
+    i : longint;
+  begin
+    for i:=1 to 10 do
+      try
+        writeln;
+      except
+        try
+          writeln;
+          continue;
+        finally
+          writeln;
+        end;
+      end;
+  end;
+
+
 begin
 end.