Fix regressions.

pgenutil.pas:
  + new function maybe_add_pending_specialization() to add a pending specialization if it belongs to the current unit
  * generate_specialization_phase2: don't set up the owner as this leads to problems when using overloaded generic routines and don't add it to the pending list if it's a procdef
ncal.pas, tcallnode:
  * pass_typecheck: if we have a specialization then add it to the pending specializations once we know that we use it

git-svn-id: trunk@33843 -
This commit is contained in:
svenbarth 2016-05-28 22:12:45 +00:00
parent 7c5c5d2e4b
commit 1bd43d9e37
2 changed files with 20 additions and 4 deletions

View File

@ -304,6 +304,7 @@ implementation
symconst,defutil,defcmp,
htypechk,pass_1,
ncnv,nflw,nld,ninl,nadd,ncon,nmem,nset,nobjc,
pgenutil,
ngenutil,objcutil,
procinfo,cpuinfo,
wpobase;
@ -3603,6 +3604,8 @@ implementation
{ if the final procedure definition is not yet owned,
ensure that it is }
procdefinition.register_def;
if procdefinition.is_specialization and (procdefinition.typ=procdef) then
maybe_add_pending_specialization(procdefinition);
candidates.free;
end; { end of procedure to call determination }

View File

@ -52,6 +52,7 @@ uses
function could_be_generic(const name:tidstring):boolean;inline;
procedure generate_specialization_procs;
procedure maybe_add_pending_specialization(def:tdef);
procedure specialization_init(genericdef:tdef;var state:tspecializationstate);
procedure specialization_done(var state:tspecializationstate);
@ -1072,10 +1073,9 @@ uses
specialization_done(state);
if not assigned(result.owner) then
result.ChangeOwner(specializest);
current_module.pendingspecializations.add(result.typename,result);
{ procdefs are only added once we know which overload we use }
if result.typ<>procdef then
current_module.pendingspecializations.add(result.typename,result);
end;
generictypelist.free;
@ -1650,4 +1650,17 @@ uses
end;
procedure maybe_add_pending_specialization(def:tdef);
var
hmodule : tmodule;
st : tsymtable;
begin
st:=def.owner;
while st.symtabletype in [localsymtable] do
st:=st.defowner.owner;
hmodule:=find_module_from_symtable(st);
if tstoreddef(def).is_specialization and (hmodule=current_module) then
current_module.pendingspecializations.add(def.typename,def);
end;
end.