Browse Source

* only don't pre-finalize funcret temps that are passed by reference to the
called function, fixes webtbs/tw3742.pp after r21955 (looked at wrong
testsuite results :/ )

git-svn-id: trunk@21963 -

Jonas Maebe 13 years ago
parent
commit
b50d0aa3d0
3 changed files with 11 additions and 2 deletions
  1. 5 1
      compiler/nbas.pas
  2. 5 0
      compiler/ncal.pas
  3. 1 1
      compiler/ncgbas.pas

+ 5 - 1
compiler/nbas.pas

@@ -140,7 +140,11 @@ interface
          { this temp only allows reading (makes it possible to safely use as
            reference under more circumstances)
          }
-         ti_readonly);
+         ti_readonly,
+         { if this is a managed temp, it doesn't have to be finalised before use
+         }
+         ti_nofini
+         );
        ttempinfoflags = set of ttempinfoflag;
 
      const

+ 5 - 0
compiler/ncal.pas

@@ -2392,6 +2392,11 @@ implementation
                   (cnf_do_inline in callnodeflags) and
                   not(tabstractvarsym(tprocdef(procdefinition).funcretsym).varregable in [vr_none,vr_addr]));
                 include(temp.flags,nf_is_funcret);
+                { if a managed type is returned by reference, assigning something
+                  to the result on the caller side will take care of decreasing
+                  the reference count }
+                if paramanager.ret_in_param(resultdef,procdefinition.proccalloption) then
+                  include(ttempcreatenode(temp).tempinfo^.flags,ti_nofini);
                 add_init_statement(temp);
                 { When the function result is not used in an inlined function
                   we need to delete the temp. This can currently only be done by

+ 1 - 1
compiler/ncgbas.pas

@@ -407,7 +407,7 @@ interface
                 { the temp could have been used previously either because the memory location was reused or
                   because we're in a loop. In case it's used as a function result, that doesn't matter
                   because it will be finalized when assigned to. }
-                if not(nf_is_funcret in flags) then
+                if not(ti_nofini in tempinfo^.flags) then
                   hlcg.g_finalize(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.location.reference);
               end
             else if (ti_may_be_in_reg in tempinfo^.flags) then