diff --git a/compiler/pgenutil.pas b/compiler/pgenutil.pas index cb444833af..f618ffad9d 100644 --- a/compiler/pgenutil.pas +++ b/compiler/pgenutil.pas @@ -680,7 +680,7 @@ uses for i:=0 to unnamed_syms.count-1 do begin sym:=tsym(unnamed_syms[i]); - sym.ChangeOwnerAndName(owner.symlist,sym.realname); + sym.ChangeOwnerAndName(owner,sym.realname); end; unnamed_syms.clear; end; diff --git a/compiler/symtype.pas b/compiler/symtype.pas index 99585c2c62..3c10ba8fb5 100644 --- a/compiler/symtype.pas +++ b/compiler/symtype.pas @@ -143,6 +143,7 @@ interface procedure buildderef;virtual; procedure deref;virtual; procedure ChangeOwner(st:TSymtable); + procedure ChangeOwnerAndName(st:TSymtable;const aname:tsymstr); procedure IncRefCount; procedure IncRefCountBy(AValue : longint); procedure MaybeCreateRefList; @@ -687,6 +688,15 @@ implementation end; + procedure tsym.ChangeOwnerAndName(st:TSymtable;const aname:tsymstr); + begin + if assigned(owner) and owner.SymList.OwnsObjects then + owner.symlist.extract(self); + Owner:=st; + inherited ChangeOwnerAndName(Owner.SymList,aname); + end; + + {**************************************************************************** tpropaccesslist ****************************************************************************}