|
@@ -41,6 +41,8 @@ interface
|
|
|
|
|
|
procedure read_public_and_external(vs: tabstractvarsym);
|
|
|
|
|
|
+ procedure try_consume_sectiondirective(var asection: ansistring);
|
|
|
+
|
|
|
implementation
|
|
|
|
|
|
uses
|
|
@@ -925,7 +927,7 @@ implementation
|
|
|
is_external_var,
|
|
|
is_weak_external,
|
|
|
is_public_var : boolean;
|
|
|
- dll_name,
|
|
|
+ dll_name,section_name,
|
|
|
C_name,mangledname : string;
|
|
|
begin
|
|
|
{ only allowed for one var }
|
|
@@ -940,6 +942,7 @@ implementation
|
|
|
is_cdecl:=false;
|
|
|
is_external_var:=false;
|
|
|
is_public_var:=false;
|
|
|
+ section_name := '';
|
|
|
C_name:=vs.realname;
|
|
|
|
|
|
{ macpas specific handling due to some switches}
|
|
@@ -992,6 +995,10 @@ implementation
|
|
|
is_public_var:=true;
|
|
|
if try_to_consume(_NAME) then
|
|
|
C_name:=get_stringconst;
|
|
|
+ if (target_info.system in systems_allow_section_no_semicolon) and
|
|
|
+ (vs.typ=staticvarsym) and
|
|
|
+ try_to_consume (_SECTION) then
|
|
|
+ section_name:=get_stringconst;
|
|
|
consume(_SEMICOLON);
|
|
|
end;
|
|
|
|
|
@@ -1000,6 +1007,14 @@ implementation
|
|
|
(target_info.system in systems_all_windows) then
|
|
|
include(vs.varoptions,vo_is_dll_var);
|
|
|
|
|
|
+ { This can only happen if vs.typ=staticvarsym }
|
|
|
+ if section_name<>'' then
|
|
|
+ begin
|
|
|
+ tstaticvarsym(vs).section:=section_name;
|
|
|
+ include(vs.varoptions,vo_has_section);
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
{ Add C _ prefix }
|
|
|
if is_cdecl or
|
|
|
(
|
|
@@ -1272,7 +1287,7 @@ implementation
|
|
|
hintsymoptions : tsymoptions;
|
|
|
deprecatedmsg : pshortstring;
|
|
|
old_block_type : tblock_type;
|
|
|
- section : ansistring;
|
|
|
+ sectionname : ansistring;
|
|
|
begin
|
|
|
old_block_type:=block_type;
|
|
|
block_type:=bt_var;
|
|
@@ -1415,10 +1430,12 @@ implementation
|
|
|
read_public_and_external_sc(sc);
|
|
|
|
|
|
{ try to parse a section directive }
|
|
|
- if (target_info.system in systems_embedded) and (idtoken=_SECTION) then
|
|
|
+ if (target_info.system in systems_allow_section) and
|
|
|
+ (symtablestack.top.symtabletype in [staticsymtable,globalsymtable]) and
|
|
|
+ (idtoken=_SECTION) then
|
|
|
begin
|
|
|
- try_consume_sectiondirective(section);
|
|
|
- if section<>'' then
|
|
|
+ try_consume_sectiondirective(sectionname);
|
|
|
+ if sectionname<>'' then
|
|
|
begin
|
|
|
for i:=0 to sc.count-1 do
|
|
|
begin
|
|
@@ -1427,7 +1444,8 @@ implementation
|
|
|
Message(parser_e_externals_no_section);
|
|
|
if vs.typ<>staticvarsym then
|
|
|
Message(parser_e_section_no_locals);
|
|
|
- tstaticvarsym(vs).section:=section;
|
|
|
+ tstaticvarsym(vs).section:=sectionname;
|
|
|
+ include(vs.varoptions, vo_has_section);
|
|
|
end;
|
|
|
end;
|
|
|
end;
|