Quellcode durchsuchen

* The code generator of the exit statement must set the fc_gotolabel flag in flowcontrol for inlined routines/code blocks. It fixes the incorrect assumption that such exit statements terminate the main routine.

git-svn-id: trunk@47683 -
yury vor 4 Jahren
Ursprung
Commit
d72566169e
3 geänderte Dateien mit 7 neuen und 2 gelöschten Zeilen
  1. 2 1
      compiler/ncgbas.pas
  2. 2 0
      compiler/ncgflw.pas
  3. 3 1
      compiler/pass_2.pas

+ 2 - 1
compiler/ncgbas.pas

@@ -443,6 +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);
           end;
 
         { do second pass on left node }
@@ -468,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]);
+            flowcontrol:=oldflowcontrol+(flowcontrol - [fc_exit,fc_block_with_exit]);
           end;
       end;
 

+ 2 - 0
compiler/ncgflw.pas

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

+ 3 - 1
compiler/pass_2.pas

@@ -43,7 +43,9 @@ uses
          fc_unwind_loop,
          { the left side of an expression is already handled, so we are
            not allowed to do ssl }
-         fc_lefthandled);
+         fc_lefthandled,
+         { in block which contains the exit statement }
+         fc_block_with_exit);
 
        tflowcontrol = set of tenumflowcontrol;