Przeglądaj źródła

* properly firstpass nodes when inc(...) is converted into ...:=...+x, resolves #27471

git-svn-id: trunk@29742 -
florian 10 lat temu
rodzic
commit
0dfbba86f3
2 zmienionych plików z 24 dodań i 1 usunięć
  1. 8 0
      compiler/ninl.pas
  2. 16 1
      compiler/nutils.pas

+ 8 - 0
compiler/ninl.pas

@@ -3848,10 +3848,18 @@ implementation
                  get_max_value(resultnode.resultdef)))
                  get_max_value(resultnode.resultdef)))
              else
              else
                inserttypeconv(hpp,resultnode.resultdef);
                inserttypeconv(hpp,resultnode.resultdef);
+
              { avoid any possible warnings }
              { avoid any possible warnings }
              inserttypeconv_internal(hpp,resultnode.resultdef);
              inserttypeconv_internal(hpp,resultnode.resultdef);
 
 
              addstatement(newstatement,cassignmentnode.create(resultnode,hpp));
              addstatement(newstatement,cassignmentnode.create(resultnode,hpp));
+
+             { force pass 1, so copied tries get first pass'ed as well and flags like nf_write, nf_call_unique
+               get set right }
+             node_reset_flags(newstatement.statement,[nf_pass1_done]);
+             { firstpass it }
+             firstpass(tnode(newstatement.left));
+
              { deallocate the temp }
              { deallocate the temp }
              if assigned(tempnode) then
              if assigned(tempnode) then
                addstatement(newstatement,ctempdeletenode.create(tempnode));
                addstatement(newstatement,ctempdeletenode.create(tempnode));

+ 16 - 1
compiler/nutils.pas

@@ -141,6 +141,9 @@ interface
     }
     }
     function get_open_const_array(p : tnode) : tnode;
     function get_open_const_array(p : tnode) : tnode;
 
 
+    { excludes the flags passed in nf from the node tree passed }
+    procedure node_reset_flags(p : tnode;nf : tnodeflags);
+
 implementation
 implementation
 
 
     uses
     uses
@@ -1190,7 +1193,6 @@ implementation
           result:=fen_norecurse_true;
           result:=fen_norecurse_true;
       end;
       end;
 
 
-
     function might_have_sideeffects(n : tnode) : boolean;
     function might_have_sideeffects(n : tnode) : boolean;
       begin
       begin
         result:=foreachnodestatic(n,@check_for_sideeffect,nil);
         result:=foreachnodestatic(n,@check_for_sideeffect,nil);
@@ -1251,4 +1253,17 @@ implementation
           result:=get_open_const_array(taddrnode(tderefnode(result).left).left);
           result:=get_open_const_array(taddrnode(tderefnode(result).left).left);
       end;
       end;
 
 
+
+    function do_node_reset_flags(var n: tnode; arg: pointer): foreachnoderesult;
+      begin
+        result:=fen_false;
+        n.flags:=n.flags-tnodeflags(arg^);
+      end;
+
+
+    procedure node_reset_flags(p : tnode; nf : tnodeflags);
+      begin
+        foreachnodestatic(p,@do_node_reset_flags,@nf);
+      end;
+
 end.
 end.