mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 14:29:14 +02:00
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:
parent
c57c039362
commit
f3af6a83f7
@ -165,7 +165,7 @@ implementation
|
|||||||
var
|
var
|
||||||
orgname : TIDString;
|
orgname : TIDString;
|
||||||
hdef : tdef;
|
hdef : tdef;
|
||||||
sym : tsym;
|
sym, tmp : tsym;
|
||||||
dummysymoptions : tsymoptions;
|
dummysymoptions : tsymoptions;
|
||||||
deprecatedmsg : pshortstring;
|
deprecatedmsg : pshortstring;
|
||||||
storetokenpos,filepos : tfileposinfo;
|
storetokenpos,filepos : tfileposinfo;
|
||||||
@ -173,6 +173,8 @@ implementation
|
|||||||
skipequal : boolean;
|
skipequal : boolean;
|
||||||
tclist : tasmlist;
|
tclist : tasmlist;
|
||||||
varspez : tvarspez;
|
varspez : tvarspez;
|
||||||
|
static_name : string;
|
||||||
|
sl : tpropaccesslist;
|
||||||
begin
|
begin
|
||||||
old_block_type:=block_type;
|
old_block_type:=block_type;
|
||||||
block_type:=bt_const;
|
block_type:=bt_const;
|
||||||
@ -218,10 +220,30 @@ implementation
|
|||||||
varspez:=vs_const
|
varspez:=vs_const
|
||||||
else
|
else
|
||||||
varspez:=vs_value;
|
varspez:=vs_value;
|
||||||
sym:=tstaticvarsym.create(orgname,varspez,hdef,[]);
|
{ if we are dealing with structure const then we need to handle it as a
|
||||||
sym.visibility:=symtablestack.top.currentvisibility;
|
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;
|
current_tokenpos:=storetokenpos;
|
||||||
symtablestack.top.insert(sym);
|
|
||||||
{ procvar can have proc directives, but not type references }
|
{ procvar can have proc directives, but not type references }
|
||||||
if (hdef.typ=procvardef) and
|
if (hdef.typ=procvardef) and
|
||||||
(hdef.typesym=nil) then
|
(hdef.typesym=nil) then
|
||||||
|
@ -1302,9 +1302,17 @@ implementation
|
|||||||
end;
|
end;
|
||||||
staticvarsym:
|
staticvarsym:
|
||||||
begin
|
begin
|
||||||
// typed constant is a staticvarsym
|
{ typed constant is a staticvarsym
|
||||||
|
now they are absolutevarsym }
|
||||||
p1.free;
|
p1.free;
|
||||||
p1:=cloadnode.create(sym,sym.Owner);
|
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
|
end
|
||||||
else
|
else
|
||||||
internalerror(16);
|
internalerror(16);
|
||||||
|
Loading…
Reference in New Issue
Block a user