mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 06:49:38 +02:00
* use reference-counted temps for the method pointer when the method
pointer is of a reference-counted type (reverts r2165, fixes mantis #14019) * modified test for mantis #4086 (which was "fixed" by r2165) so it still works and no longer depends on whether or not the compiler uses a refcounted temp to evaluate certain expressions git-svn-id: trunk@13310 -
This commit is contained in:
parent
089ff79c3b
commit
c0e51f3e97
@ -1246,7 +1246,6 @@ implementation
|
||||
hdef : tdef;
|
||||
ptemp : ttempcreatenode;
|
||||
usederef : boolean;
|
||||
usevoidpointer : boolean;
|
||||
begin
|
||||
{ Load all complex loads into a temp to prevent
|
||||
double calls to a function. We can't simply check for a hp.nodetype=calln }
|
||||
@ -1257,33 +1256,22 @@ implementation
|
||||
usederef:=(p.resultdef.typ in [arraydef,recorddef]) or
|
||||
is_shortstring(p.resultdef) or
|
||||
is_object(p.resultdef);
|
||||
{ avoid refcount increase }
|
||||
usevoidpointer:=is_interface(p.resultdef);
|
||||
|
||||
if usederef then
|
||||
hdef:=tpointerdef.create(p.resultdef)
|
||||
else
|
||||
hdef:=p.resultdef;
|
||||
|
||||
if usevoidpointer then
|
||||
ptemp:=ctempcreatenode.create(hdef,hdef.size,tt_persistent,true);
|
||||
if usederef then
|
||||
begin
|
||||
ptemp:=ctempcreatenode.create(voidpointertype,voidpointertype.size,tt_persistent,true);
|
||||
loadp:=ctypeconvnode.create_internal(p,voidpointertype);
|
||||
refp:=ctypeconvnode.create_internal(ctemprefnode.create(ptemp),hdef);
|
||||
loadp:=caddrnode.create_internal(p);
|
||||
refp:=cderefnode.create(ctemprefnode.create(ptemp));
|
||||
end
|
||||
else
|
||||
begin
|
||||
ptemp:=ctempcreatenode.create(hdef,hdef.size,tt_persistent,true);
|
||||
if usederef then
|
||||
begin
|
||||
loadp:=caddrnode.create_internal(p);
|
||||
refp:=cderefnode.create(ctemprefnode.create(ptemp));
|
||||
end
|
||||
else
|
||||
begin
|
||||
loadp:=p;
|
||||
refp:=ctemprefnode.create(ptemp)
|
||||
end
|
||||
loadp:=p;
|
||||
refp:=ctemprefnode.create(ptemp)
|
||||
end;
|
||||
add_init_statement(ptemp);
|
||||
add_init_statement(cassignmentnode.create(
|
||||
|
@ -61,9 +61,8 @@ var
|
||||
test1: ttestclass1;
|
||||
test2: ttestclass2;
|
||||
|
||||
procedure test;
|
||||
begin
|
||||
test1:= ttestclass1.create;
|
||||
test2:= ttestclass2.create;
|
||||
writeln('*** global variable');
|
||||
po1:= pointer(itest(test1));
|
||||
itest(po1).testproc;
|
||||
@ -71,6 +70,12 @@ begin
|
||||
test2.intf:= pointer(itest(test1));
|
||||
itest(test2.intf).testproc;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
test1:= ttestclass1.create;
|
||||
test2:= ttestclass2.create;
|
||||
test;
|
||||
test1.free;
|
||||
test2.free;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user