diff options
Diffstat (limited to 'compiler/nutils.pas')
-rw-r--r-- | compiler/nutils.pas | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/compiler/nutils.pas b/compiler/nutils.pas index a802fffdf7..7cfa826a0d 100644 --- a/compiler/nutils.pas +++ b/compiler/nutils.pas @@ -1043,6 +1043,41 @@ implementation function handle_staticfield_access(sym: tsym; nested: boolean; var p1: tnode): boolean; + + function handle_generic_staticfield_access:boolean; + var + tmp : tstoreddef; + pd : tprocdef; + begin + { in case we have a specialization inside a generic (thus the static var sym does not + exist) we simply simulate a non static access to avoid unnecessary errors } + if assigned(sym.owner.defowner) and (df_specialization in tstoreddef(sym.owner.defowner).defoptions) then + begin + tmp:=tstoreddef(sym.owner.defowner); + while assigned(tmp) do + begin + if df_generic in tmp.defoptions then + begin + p1.free; + if assigned(current_procinfo) then + begin + pd:=current_procinfo.get_normal_proc.procdef; + if assigned(pd) and pd.no_self_node then + p1:=cloadvmtaddrnode.create(ctypenode.create(pd.struct)) + else + p1:=load_self_node; + end + else + p1:=load_self_node; + p1:=csubscriptnode.create(sym,p1); + exit(true); + end; + tmp:=tstoreddef(tmp.owner.defowner); + end; + end; + result:=false; + end; + var static_name: shortstring; srsymtable: tsymtable; @@ -1052,6 +1087,8 @@ implementation if (sp_static in sym.symoptions) then begin result:=true; + if handle_generic_staticfield_access then + exit; if not nested then static_name:=lower(sym.owner.name^)+'_'+sym.name else |