* 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 -
This commit is contained in:
Jonas Maebe 2012-07-23 23:55:00 +00:00
parent 93c345a099
commit b50d0aa3d0
3 changed files with 11 additions and 2 deletions

View File

@ -140,7 +140,11 @@ interface
{ this temp only allows reading (makes it possible to safely use as { this temp only allows reading (makes it possible to safely use as
reference under more circumstances) 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; ttempinfoflags = set of ttempinfoflag;
const const

View File

@ -2392,6 +2392,11 @@ implementation
(cnf_do_inline in callnodeflags) and (cnf_do_inline in callnodeflags) and
not(tabstractvarsym(tprocdef(procdefinition).funcretsym).varregable in [vr_none,vr_addr])); not(tabstractvarsym(tprocdef(procdefinition).funcretsym).varregable in [vr_none,vr_addr]));
include(temp.flags,nf_is_funcret); 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); add_init_statement(temp);
{ When the function result is not used in an inlined function { When the function result is not used in an inlined function
we need to delete the temp. This can currently only be done by we need to delete the temp. This can currently only be done by

View File

@ -407,7 +407,7 @@ interface
{ the temp could have been used previously either because the memory location was reused or { 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 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. } 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); hlcg.g_finalize(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.location.reference);
end end
else if (ti_may_be_in_reg in tempinfo^.flags) then else if (ti_may_be_in_reg in tempinfo^.flags) then