Browse Source

* Win64 exception handling: don't reset fc_unwind control flow flag at the beginning of try..except blocks. Resolves #24342.

git-svn-id: trunk@24385 -
sergei 12 years ago
parent
commit
c7937f6736
3 changed files with 27 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/x86_64/nx64flw.pas
  3. 25 0
      tests/test/cg/ttryfin5.pp

+ 1 - 0
.gitattributes

@@ -10373,6 +10373,7 @@ tests/test/cg/ttryfin1.pp svneol=native#text/plain
 tests/test/cg/ttryfin2.pp svneol=native#text/plain
 tests/test/cg/ttryfin3.pp svneol=native#text/plain
 tests/test/cg/ttryfin4.pp svneol=native#text/plain
+tests/test/cg/ttryfin5.pp svneol=native#text/plain
 tests/test/cg/tumin.pp svneol=native#text/plain
 tests/test/cg/tvec.pp svneol=native#text/plain
 tests/test/cg/uprintf3.pp svneol=native#text/plain

+ 1 - 1
compiler/x86_64/nx64flw.pas

@@ -427,7 +427,7 @@ procedure tx64tryexceptnode.pass_generate_code;
     location_reset(location,LOC_VOID,OS_NO);
 
     oldflowcontrol:=flowcontrol;
-    flowcontrol:=[fc_inflowcontrol];
+    flowcontrol:=flowcontrol*[fc_unwind]+[fc_inflowcontrol];
     { this can be called recursivly }
     oldBreakLabel:=nil;
     oldContinueLabel:=nil;

+ 25 - 0
tests/test/cg/ttryfin5.pp

@@ -0,0 +1,25 @@
+{$mode objfpc}
+
+var
+  counter: integer;
+
+{ exit statement in try..except must not bypass finally code of outer try..finally }
+procedure test;
+ begin
+   try
+     try
+       inc(counter);
+       exit;
+     except
+     end;
+   finally
+     inc(counter);
+   end;
+ end;
+ 
+ begin
+   counter:=0;
+   test;
+   if counter<>2 then
+     Halt(1);
+ end.