2
0
Эх сурвалжийг харах

* fixed toperator5 after r8558. The inlining logic did not take into
account that an unmodified value parameter's address could also be
passed as the address of the complex return value (and thus be modified
indirectly after all)

git-svn-id: trunk@8570 -

Jonas Maebe 18 жил өмнө
parent
commit
2146ad614c
1 өөрчлөгдсөн 10 нэмэгдсэн , 1 устгасан
  1. 10 1
      compiler/ncal.pas

+ 10 - 1
compiler/ncal.pas

@@ -2973,8 +2973,17 @@ implementation
                      foreachnodestatic(para.left,@nonlocalvars,pointer(symtableproc))) or
                     { value parameters of which we know they are modified by }
                     { definition have to be copied to a temp                 }
+                    { the same goes for cases of "x:=f(x)" where x is passed }
+                    { as value parameter to f(), at least if we optimized    }
+                    { invocation by setting the funcretnode to x to avoid    }
+                    { assignment afterwards (since x may be read inside the  }
+                    { function after it modified result==x)                  }
                     ((para.parasym.varspez = vs_value) and
-                     not(para.parasym.varstate in [vs_initialised,vs_declared,vs_read])) or
+                     (not(para.parasym.varstate in [vs_initialised,vs_declared,vs_read]) or
+                      (assigned(aktassignmentnode) and
+                       (aktassignmentnode.right=self) and
+                       (nf_assign_done_in_right in aktassignmentnode.flags) and
+                       aktassignmentnode.left.isequal(para.left)))) or
                     { the compiler expects that it can take the address of parameters passed by reference in
                       the case of const so we can't replace the node simply by a constant node
                       When playing with this code, ensure that