* access static fields by a absolute sym pointing to the symbol for the space allocation, resolves #14124

git-svn-id: trunk@13512 -
This commit is contained in:
florian 2009-08-10 18:46:23 +00:00
parent 6a6a6a6e6f
commit 10ede51609
5 changed files with 52 additions and 7 deletions

2
.gitattributes vendored
View File

@ -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

View File

@ -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;

View File

@ -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

11
tests/webtbs/tw14124.pp Normal file
View File

@ -0,0 +1,11 @@
program project1;
uses
uw14124;
type
T = specialize TGenericType<Integer>;
begin
end.

24
tests/webtbs/uw14124.pp Normal file
View File

@ -0,0 +1,24 @@
unit uw14124;
{$mode objfpc}{$H+}
{$static on}
interface
type
generic TGenericType<TParamType> = 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.