View Issue Details

IDProjectCategoryView StatusLast Update
0035841FPCCompilerpublic2019-07-12 19:49
ReporterJ. Gareth MoretonAssigned ToFlorian 
PrioritynormalSeverityminorReproducibilityalways
Status feedbackResolutionopen 
Platformx86_64-win64OSMicrosoft WindowsOS Version10 Professional
Product Version3.0.4Product Buildr42348 
Target VersionFixed in Version 
Summary0035841: Split from 0032913 - Nested try blocks with Exit cause assembler error
DescriptionSplit from issue 0032913. If you have the following construct, the assembly of the source code fails because the label that Exit is meant to jump to is never created:

try
  ...
except
  try
    ...
    Exit;
  finally
    ...
  end;
end;

The following patch fixes this issue.
Steps To ReproduceSee above.
Additional InformationThis bug was previously only visible if there was no code was present in the try part of the try..except block, because that arrangement raised an internal error instead.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files
  • i35841.patch (1,767 bytes)
    Index: compiler/x86_64/nx64flw.pas
    ===================================================================
    --- compiler/x86_64/nx64flw.pas	(revision 42348)
    +++ compiler/x86_64/nx64flw.pas	(working copy)
    @@ -311,6 +311,12 @@
               InternalError(2014031601);
           end;
     
    +    { i32913 - if the try..finally block is also inside a try..finally or
    +      try..except block, make a note of any Exit calls so all necessary labels
    +      are generated. [Kit] }
    +    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
    +      Include(oldflowcontrol, fc_exit);
    +
         flowcontrol:=[fc_inflowcontrol];
         cg.a_label(current_asmdata.CurrAsmList,finallylabel);
         { generate finally code as a separate procedure }
    @@ -421,6 +427,12 @@
             current_procinfo.CurrBreakLabel:=breakexceptlabel;
           end;
     
    +    { i32913 - if the try..finally block is also inside a try..finally or
    +      try..except block, make a note of any Exit calls so all necessary labels
    +      are generated. [Kit] }
    +    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
    +      Include(oldflowcontrol, fc_exit);
    +
         flowcontrol:=[fc_inflowcontrol];
         { on statements }
         if assigned(right) then
    @@ -509,6 +521,12 @@
         { restore all saved labels }
         endexceptlabel:=oldendexceptlabel;
     
    +    { i32913 - if the try..finally block is also inside a try..finally or
    +      try..except block, make a note of any Exit calls so all necessary labels
    +      are generated. [Kit] }
    +    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
    +      Include(oldflowcontrol, fc_exit);
    +
         { restore the control flow labels }
         current_procinfo.CurrExitLabel:=oldCurrExitLabel;
         if assigned(oldBreakLabel) then
    
    i35841.patch (1,767 bytes)

Relationships

related to 0032913 feedbackFlorian nested try blocks with exit gives Error: Internal error 

Activities

J. Gareth Moreton

2019-07-12 19:33

developer  

i35841.patch (1,767 bytes)
Index: compiler/x86_64/nx64flw.pas
===================================================================
--- compiler/x86_64/nx64flw.pas	(revision 42348)
+++ compiler/x86_64/nx64flw.pas	(working copy)
@@ -311,6 +311,12 @@
           InternalError(2014031601);
       end;
 
+    { i32913 - if the try..finally block is also inside a try..finally or
+      try..except block, make a note of any Exit calls so all necessary labels
+      are generated. [Kit] }
+    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
+      Include(oldflowcontrol, fc_exit);
+
     flowcontrol:=[fc_inflowcontrol];
     cg.a_label(current_asmdata.CurrAsmList,finallylabel);
     { generate finally code as a separate procedure }
@@ -421,6 +427,12 @@
         current_procinfo.CurrBreakLabel:=breakexceptlabel;
       end;
 
+    { i32913 - if the try..finally block is also inside a try..finally or
+      try..except block, make a note of any Exit calls so all necessary labels
+      are generated. [Kit] }
+    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
+      Include(oldflowcontrol, fc_exit);
+
     flowcontrol:=[fc_inflowcontrol];
     { on statements }
     if assigned(right) then
@@ -509,6 +521,12 @@
     { restore all saved labels }
     endexceptlabel:=oldendexceptlabel;
 
+    { i32913 - if the try..finally block is also inside a try..finally or
+      try..except block, make a note of any Exit calls so all necessary labels
+      are generated. [Kit] }
+    if (fc_exit in flowcontrol) and (fc_inflowcontrol in oldflowcontrol) then
+      Include(oldflowcontrol, fc_exit);
+
     { restore the control flow labels }
     current_procinfo.CurrExitLabel:=oldCurrExitLabel;
     if assigned(oldBreakLabel) then
i35841.patch (1,767 bytes)

Issue History

Date Modified Username Field Change
2019-07-12 19:33 J. Gareth Moreton New Issue
2019-07-12 19:33 J. Gareth Moreton Status new => assigned
2019-07-12 19:33 J. Gareth Moreton Assigned To => Florian
2019-07-12 19:33 J. Gareth Moreton File Added: i35841.patch
2019-07-12 19:34 J. Gareth Moreton Relationship added related to 0032913
2019-07-12 19:49 J. Gareth Moreton Status assigned => feedback
2019-07-12 19:49 J. Gareth Moreton FPCTarget => -