diff --git a/.gitattributes b/.gitattributes index b8bca769b1..f8ca74d62a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9215,6 +9215,7 @@ tests/webtbs/tw1407.pp svneol=native#text/plain tests/webtbs/tw1408.pp svneol=native#text/plain tests/webtbs/tw1409.pp svneol=native#text/plain tests/webtbs/tw1412.pp svneol=native#text/plain +tests/webtbs/tw14124.pp svneol=native#text/plain tests/webtbs/tw14134.pp svneol=native#text/plain tests/webtbs/tw1414.pp svneol=native#text/plain tests/webtbs/tw14143.pp svneol=native#text/plain @@ -10104,6 +10105,7 @@ tests/webtbs/uw13345b.pp svneol=native#text/plain tests/webtbs/uw13345c.pp svneol=native#text/plain tests/webtbs/uw13345y.pp svneol=native#text/plain tests/webtbs/uw13583.pp svneol=native#text/plain +tests/webtbs/uw14124.pp svneol=native#text/plain tests/webtbs/uw2004.inc svneol=native#text/plain tests/webtbs/uw2040.pp svneol=native#text/plain tests/webtbs/uw2266a.inc svneol=native#text/plain diff --git a/compiler/pdecvar.pas b/compiler/pdecvar.pas index 76b2ecc7c7..958e0bf2c8 100644 --- a/compiler/pdecvar.pas +++ b/compiler/pdecvar.pas @@ -1315,6 +1315,7 @@ implementation tempdef: tdef; is_first_field: boolean; {$endif powerpc or powerpc64} + sl : tpropaccesslist; begin recst:=tabstractrecordsymtable(symtablestack.top); {$if defined(powerpc) or defined(powerpc64)} @@ -1429,9 +1430,14 @@ implementation begin fieldvs:=tfieldvarsym(sc[i]); include(fieldvs.symoptions,sp_static); - hstaticvs:=tstaticvarsym.create('$'+lower(symtablestack.top.name^)+'_'+fieldvs.name,vs_value,hdef,[]); + { generate the symbol which reserves the space } + hstaticvs:=tstaticvarsym.create('$_static_'+lower(symtablestack.top.name^)+'_'+fieldvs.name,vs_value,hdef,[]); recst.defowner.owner.insert(hstaticvs); insertbssdata(hstaticvs); + { generate the symbol for the access } + sl:=tpropaccesslist.create; + sl.addsym(sl_load,hstaticvs); + recst.insert(tabsolutevarsym.create_ref('$'+lower(symtablestack.top.name^)+'_'+fieldvs.name,hdef,sl)); end; consume(_SEMICOLON); end; diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 2f967dc904..edf0e59143 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1200,12 +1200,14 @@ implementation begin if (sp_static in sym.symoptions) then begin - static_name:=lower(sym.owner.name^)+'_'+sym.name; - searchsym(static_name,sym,srsymtable); - if assigned(sym) then - check_hints(sym,sym.symoptions); - p1.free; - p1:=cloadnode.create(sym,srsymtable); + static_name:=lower(sym.owner.name^)+'_'+sym.name; + searchsym_in_class(tobjectdef(sym.owner.defowner),tobjectdef(sym.owner.defowner),static_name,sym,srsymtable); + if assigned(sym) then + check_hints(sym,sym.symoptions); + p1.free; + p1:=nil; + { static syms are always stored as absolutevarsym to handle scope and storage properly } + propaccesslist_to_node(p1,nil,tabsolutevarsym(sym).ref); end else begin diff --git a/tests/webtbs/tw14124.pp b/tests/webtbs/tw14124.pp new file mode 100644 index 0000000000..5a24ae5bb1 --- /dev/null +++ b/tests/webtbs/tw14124.pp @@ -0,0 +1,11 @@ +program project1; + +uses + uw14124; + +type + + T = specialize TGenericType; + +begin +end. diff --git a/tests/webtbs/uw14124.pp b/tests/webtbs/uw14124.pp new file mode 100644 index 0000000000..88f7dd19b2 --- /dev/null +++ b/tests/webtbs/uw14124.pp @@ -0,0 +1,24 @@ +unit uw14124; + +{$mode objfpc}{$H+} +{$static on} + +interface + +type + generic TGenericType = class + var private + FDefault: TParamType; static; + F: TParamType; + public + procedure P; + end; + +implementation + +procedure TGenericType.P; +begin + F := FDefault; // <====== unit1.pas(21,16) Fatal: Internal error 200108121 +end; + +end. \ No newline at end of file