Bläddra i källkod

* 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 -

yury 4 år sedan
förälder
incheckning
8b7c5666a2
4 ändrade filer med 11 tillägg och 5 borttagningar
  1. 2 2
      compiler/ncgbas.pas
  2. 1 1
      compiler/ncgflw.pas
  3. 3 2
      compiler/pass_2.pas
  4. 5 0
      compiler/psub.pas

+ 2 - 2
compiler/ncgbas.pas

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

+ 1 - 1
compiler/ncgflw.pas

@@ -404,7 +404,7 @@ implementation
       begin
       begin
          location_reset(location,LOC_VOID,OS_NO);
          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_gotolabel);
          include(flowcontrol,fc_exit);
          include(flowcontrol,fc_exit);
          if assigned(left) then
          if assigned(left) then

+ 3 - 2
compiler/pass_2.pas

@@ -44,8 +44,9 @@ uses
          { the left side of an expression is already handled, so we are
          { the left side of an expression is already handled, so we are
            not allowed to do ssl }
            not allowed to do ssl }
          fc_lefthandled,
          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;
        tflowcontrol = set of tenumflowcontrol;
 
 

+ 5 - 0
compiler/psub.pas

@@ -927,6 +927,11 @@ implementation
         exitlabel_asmnode:=casmnode.create_get_position;
         exitlabel_asmnode:=casmnode.create_get_position;
         temps_finalized:=false;
         temps_finalized:=false;
         bodyexitcode:=generate_bodyexit_block;
         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,
         { Generate procedure by combining init+body+final,
           depending on the implicit finally we need to add
           depending on the implicit finally we need to add