Sfoglia il codice sorgente

* few fixes to psabieh, mainly related to nested exception handling

git-svn-id: branches/debug_eh@41385 -
florian 6 anni fa
parent
commit
4b66dc0a94
2 ha cambiato i file con 27 aggiunte e 5 eliminazioni
  1. 20 5
      compiler/ncgflw.pas
  2. 7 0
      compiler/psabiehpi.pas

+ 20 - 5
compiler/ncgflw.pas

@@ -122,6 +122,8 @@ interface
          class procedure end_catch(list: TAsmList); virtual;
          { called for a catch all exception }
          class procedure catch_all_start(list: TAsmList); virtual;
+         { called after the catch all exception has been started with new_exception }
+         class procedure catch_all_add(list: TAsmList); virtual;
          class procedure catch_all_end(list: TAsmList); virtual;
          class procedure cleanupobjectstack(list: TAsmList); virtual;
          class procedure popaddrstack(list: TAsmList); virtual;
@@ -800,6 +802,12 @@ implementation
       end;
 
 
+    class procedure tcgexceptionstatehandler.catch_all_add(list: TAsmList);
+      begin
+        { nothing to do by default }
+      end;
+
+
     class procedure tcgexceptionstatehandler.catch_all_end(list: TAsmList);
       begin
         { nothing to do by default }
@@ -955,6 +963,7 @@ implementation
                  flowcontrol:=trystate.oldflowcontrol*[fc_inflowcontrol,fc_catching_exceptions];
                  cexceptionstatehandler.get_exception_temps(current_asmdata.CurrAsmList,destroytemps);
                  cexceptionstatehandler.new_exception(current_asmdata.CurrAsmList,destroytemps,tek_except,doobjectdestroyandreraisestate);
+                 cexceptionstatehandler.catch_all_add(current_asmdata.CurrAsmList);
                  { the flowcontrol from the default except-block must be merged
                    with the flowcontrol flags potentially set by the
                    on-statements handled above (secondpass(right)), as they are
@@ -1422,16 +1431,22 @@ implementation
             CurrentAction:=psabiehprocinfo.CurrentAction;
             psabiehprocinfo.PopAction(CurrentAction);
 
-            ReRaiseLandingPad:=TPSABIEHAction.Create(nil);
-            psabiehprocinfo.PushAction(ReRaiseLandingPad);
-            psabiehprocinfo.PushLandingPad(ReRaiseLandingPad);
+            if not(fc_catching_exceptions in flowcontrol) then
+              begin
+                ReRaiseLandingPad:=TPSABIEHAction.Create(nil);
+                psabiehprocinfo.PushAction(ReRaiseLandingPad);
+                psabiehprocinfo.PushLandingPad(ReRaiseLandingPad);
+              end;
           end;
         hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_reraise',[],nil).resetiftemp;
         if assigned(CurrentLandingPad) then
           begin
             psabiehprocinfo.CreateNewPSABIEHCallsite;
-            psabiehprocinfo.PopLandingPad(psabiehprocinfo.CurrentLandingPad);
-            psabiehprocinfo.PopAction(ReRaiseLandingPad);
+            if not(fc_catching_exceptions in flowcontrol) then
+              begin
+                psabiehprocinfo.PopLandingPad(psabiehprocinfo.CurrentLandingPad);
+                psabiehprocinfo.PopAction(ReRaiseLandingPad);
+              end;
 
             psabiehprocinfo.PushAction(CurrentAction);
             psabiehprocinfo.PushLandingPad(CurrentLandingPad);

+ 7 - 0
compiler/psabiehpi.pas

@@ -140,6 +140,7 @@ implementation
          { called for a catch all exception }
          class procedure catch_all_start(list: TAsmList); override;
          class procedure catch_all_end(list: TAsmList); override;
+         class procedure catch_all_add(list: TAsmList); override;
          class procedure cleanupobjectstack(list: TAsmList); override;
          class procedure popaddrstack(list: TAsmList); override;
        end;
@@ -661,6 +662,12 @@ implementation
       end;
 
 
+    class procedure tpsabiehexceptionstatehandler.catch_all_add(list: TAsmList);
+      begin
+        (current_procinfo as tpsabiehprocinfo).CurrentAction.AddAction(nil);
+      end;
+
+
     class procedure tpsabiehexceptionstatehandler.catch_all_end(list: TAsmList);
       begin
         hlcg.g_call_system_proc(list,'fpc_psabi_end_catch',[],nil).resetiftemp;