* ensure that local variables and parameters moved to a parentfpstruct aren't

initialised and finalised twice (once at their original location, and once
    when the parentfpstruct is initialised/finalised)

git-svn-id: trunk@34374 -
This commit is contained in:
Jonas Maebe 2016-08-24 16:41:07 +00:00
parent 18a59dddb9
commit 18d728eb72

View File

@ -202,6 +202,21 @@ implementation
class function tnodeutils.initialize_data_node(p:tnode; force: boolean):tnode;
begin
{ prevent initialisation of hidden syms that were moved to
parentfpstructs: the original symbol isn't used anymore, the version
in parentfpstruct will be initialised when that struct gets initialised,
and references to it will actually be translated into references to the
field in the parentfpstruct (so we'll initialise it twice) }
if (target_info.system in systems_fpnestedstruct) and
(p.nodetype=loadn) and
(tloadnode(p).symtableentry.typ=localvarsym) and
(tloadnode(p).symtableentry.visibility=vis_hidden) then
begin
p.free;
result:=cnothingnode.create;
end
else
begin
if not assigned(p.resultdef) then
typecheckpass(p);
@ -234,11 +249,23 @@ implementation
nil)));
end;
end;
end;
class function tnodeutils.finalize_data_node(p:tnode):tnode;
var
hs : string;
begin
{ see comment in initialize_data_node above }
if (target_info.system in systems_fpnestedstruct) and
(p.nodetype=loadn) and
(tloadnode(p).symtableentry.typ=localvarsym) and
(tloadnode(p).symtableentry.visibility=vis_hidden) then
begin
p.free;
result:=cnothingnode.create;
end
else
begin
if not assigned(p.resultdef) then
typecheckpass(p);
@ -276,6 +303,7 @@ implementation
caddrnode.create_internal(p),
nil)));
end;
end;
class procedure tnodeutils.sym_maybe_initialize(p: TObject; arg: pointer);