* Renamed fc_block_with_exit to fc_no_direct_exit to expand its usage.

* Set fc_no_direct_exit in case when a routine has an additional implicit exit code, such as calling FreeInstance in the destructor.

git-svn-id: trunk@47749 -
This commit is contained in:
yury 2020-12-10 17:38:37 +00:00
parent 6eb37beb24
commit 8b7c5666a2
4 changed files with 11 additions and 5 deletions

View File

@ -443,7 +443,7 @@ interface
oldflowcontrol:=flowcontrol;
{ the nested block will not span an exit statement of the parent }
exclude(flowcontrol,fc_exit);
include(flowcontrol,fc_block_with_exit);
include(flowcontrol,fc_no_direct_exit);
end;
{ do second pass on left node }
@ -469,7 +469,7 @@ interface
current_procinfo.CurrExitLabel:=oldexitlabel;
{ the exit statements inside this block are not exit statements }
{ out of the parent }
flowcontrol:=oldflowcontrol+(flowcontrol - [fc_exit,fc_block_with_exit]);
flowcontrol:=oldflowcontrol+(flowcontrol - [fc_exit,fc_no_direct_exit]);
end;
end;

View File

@ -404,7 +404,7 @@ implementation
begin
location_reset(location,LOC_VOID,OS_NO);
if fc_block_with_exit in flowcontrol then
if fc_no_direct_exit in flowcontrol then
include(flowcontrol,fc_gotolabel);
include(flowcontrol,fc_exit);
if assigned(left) then

View File

@ -44,8 +44,9 @@ uses
{ the left side of an expression is already handled, so we are
not allowed to do ssl }
fc_lefthandled,
{ in block which contains the exit statement }
fc_block_with_exit);
{ in block where the exit statement jumps to an extra code instead of
immediately finishing execution of the current routine. }
fc_no_direct_exit);
tflowcontrol = set of tenumflowcontrol;

View File

@ -927,6 +927,11 @@ implementation
exitlabel_asmnode:=casmnode.create_get_position;
temps_finalized:=false;
bodyexitcode:=generate_bodyexit_block;
{ Check if bodyexitcode is not empty }
with tstatementnode(tblocknode(bodyexitcode).statements) do
if (statement.nodetype<>nothingn) or assigned(next) then
{ Indicate that the extra code is executed after the exit statement }
include(flowcontrol,fc_no_direct_exit);
{ Generate procedure by combining init+body+final,
depending on the implicit finally we need to add