compiler: put static symbol for typed consts declared in classes/records/objects into unit symtable to fix problems with linking and add absolute symbol into record symtable pointed to that static symbol (fixes test test/terecs3.pp on unixes)

git-svn-id: trunk@16588 -
This commit is contained in:
paul 2010-12-18 18:22:31 +00:00
parent c57c039362
commit f3af6a83f7
2 changed files with 35 additions and 5 deletions

View File

@ -165,7 +165,7 @@ implementation
var
orgname : TIDString;
hdef : tdef;
sym : tsym;
sym, tmp : tsym;
dummysymoptions : tsymoptions;
deprecatedmsg : pshortstring;
storetokenpos,filepos : tfileposinfo;
@ -173,6 +173,8 @@ implementation
skipequal : boolean;
tclist : tasmlist;
varspez : tvarspez;
static_name : string;
sl : tpropaccesslist;
begin
old_block_type:=block_type;
block_type:=bt_const;
@ -218,10 +220,30 @@ implementation
varspez:=vs_const
else
varspez:=vs_value;
sym:=tstaticvarsym.create(orgname,varspez,hdef,[]);
sym.visibility:=symtablestack.top.currentvisibility;
{ if we are dealing with structure const then we need to handle it as a
structure static variable: create a symbol in unit symtable and a reference
to it from the structure or linking will fail }
if symtablestack.top.symtabletype in [recordsymtable,ObjectSymtable] then
begin
{ generate the symbol which reserves the space }
static_name:=lower(generate_nested_name(symtablestack.top,'_'))+'_'+orgname;
sym:=tstaticvarsym.create('$_static_'+static_name,varspez,hdef,[]);
include(sym.symoptions,sp_internal);
tabstractrecordsymtable(symtablestack.top).get_unit_symtable.insert(sym);
{ generate the symbol for the access }
sl:=tpropaccesslist.create;
sl.addsym(sl_load,sym);
tmp:=tabsolutevarsym.create_ref(orgname,hdef,sl);
tmp.visibility:=symtablestack.top.currentvisibility;
symtablestack.top.insert(tmp);
end
else
begin
sym:=tstaticvarsym.create(orgname,varspez,hdef,[]);
sym.visibility:=symtablestack.top.currentvisibility;
symtablestack.top.insert(sym);
end;
current_tokenpos:=storetokenpos;
symtablestack.top.insert(sym);
{ procvar can have proc directives, but not type references }
if (hdef.typ=procvardef) and
(hdef.typesym=nil) then

View File

@ -1302,9 +1302,17 @@ implementation
end;
staticvarsym:
begin
// typed constant is a staticvarsym
{ typed constant is a staticvarsym
now they are absolutevarsym }
p1.free;
p1:=cloadnode.create(sym,sym.Owner);
end;
absolutevarsym:
begin
p1.free;
p1:=nil;
{ typed constants are absolutebarsyms now to handle storage properly }
propaccesslist_to_node(p1,nil,tabsolutevarsym(sym).ref);
end
else
internalerror(16);