diff --git a/compiler/ncgflw.pas b/compiler/ncgflw.pas index 601810f871..a780cada80 100644 --- a/compiler/ncgflw.pas +++ b/compiler/ncgflw.pas @@ -584,7 +584,6 @@ implementation begin current_asmdata.getjumplabel(exceptstate.exceptionlabel); exceptstate.oldflowcontrol:=flowcontrol; - flowcontrol:=[fc_inflowcontrol]; paraloc1.init; paraloc2.init; @@ -642,6 +641,8 @@ implementation longjmp'd back here } hlcg.a_cmp_const_reg_label(list,setjmpres.def,OC_NE,0,tmpresloc.register,exceptstate.exceptionlabel); setjmpres.resetiftemp; + + flowcontrol:=[fc_inflowcontrol,fc_catching_exceptions]; end; @@ -924,7 +925,7 @@ implementation { return all used control flow statements } flowcontrol:=trystate.oldflowcontrol+(doobjectdestroyandreraisestate.newflowcontrol + - trystate.newflowcontrol - [fc_inflowcontrol]); + trystate.newflowcontrol - [fc_inflowcontrol,fc_catching_exceptions]); end; @@ -1062,7 +1063,7 @@ implementation cexceptionstatehandler.unget_exception_temps(current_asmdata.CurrAsmList,excepttemps); hlcg.a_label(current_asmdata.CurrAsmList,nextonlabel); - flowcontrol:=doobjectdestroyandreraisestate.oldflowcontrol+(doobjectdestroyandreraisestate.newflowcontrol-[fc_inflowcontrol]); + flowcontrol:=doobjectdestroyandreraisestate.oldflowcontrol+(doobjectdestroyandreraisestate.newflowcontrol-[fc_inflowcontrol,fc_catching_exceptions]); paraloc1.done; current_asmdata.CurrAsmList.concat(tai_marker.create(mark_NoLineInfoEnd)); @@ -1252,7 +1253,7 @@ implementation current_procinfo.CurrContinueLabel:=oldContinueLabel; current_procinfo.CurrBreakLabel:=oldBreakLabel; end; - flowcontrol:=finallyexceptionstate.oldflowcontrol+(finallyexceptionstate.newflowcontrol-[fc_inflowcontrol]); + flowcontrol:=finallyexceptionstate.oldflowcontrol+(finallyexceptionstate.newflowcontrol-[fc_inflowcontrol,fc_catching_exceptions]); end; diff --git a/compiler/pass_2.pas b/compiler/pass_2.pas index 614d0447c5..9feb096d8d 100644 --- a/compiler/pass_2.pas +++ b/compiler/pass_2.pas @@ -35,6 +35,9 @@ uses fc_continue, fc_inflowcontrol, fc_gotolabel, + { in block that has an exception handler associated with it + (try..except, try..finally, exception block of try..except, ... } + fc_catching_exceptions, { in try block of try..finally and target uses specific unwinding } fc_unwind_exit, fc_unwind_loop, diff --git a/compiler/x86_64/nx64flw.pas b/compiler/x86_64/nx64flw.pas index f1da2a6d28..c3c67ae25b 100644 --- a/compiler/x86_64/nx64flw.pas +++ b/compiler/x86_64/nx64flw.pas @@ -293,9 +293,9 @@ procedure tx64tryfinallynode.pass_generate_code; { fc_unwind_xx tells exit/continue/break statements to emit special unwind code instead of just JMP } if not implicitframe then - flowcontrol:=flowcontrol+[fc_unwind_exit,fc_unwind_loop]; + flowcontrol:=flowcontrol+[fc_catching_exceptions,fc_unwind_exit,fc_unwind_loop]; secondpass(left); - flowcontrol:=flowcontrol-[fc_unwind_exit,fc_unwind_loop]; + flowcontrol:=flowcontrol-[fc_catching_exceptions,fc_unwind_exit,fc_unwind_loop]; if codegenerror then exit; end;