mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 21:11:23 +02:00
* Labels that are defined or referenced in a different lexical level
than their declaration need to be code generated as global asmlabels. git-svn-id: trunk@9791 -
This commit is contained in:
parent
68f340eb9c
commit
4ca3a590e8
@ -135,6 +135,7 @@ interface
|
||||
{ create new assembler label }
|
||||
procedure getlabel(out l : TAsmLabel;alt:TAsmLabeltype);
|
||||
procedure getjumplabel(out l : TAsmLabel);
|
||||
procedure getglobaljumplabel(out l : TAsmLabel);
|
||||
procedure getaddrlabel(out l : TAsmLabel);
|
||||
procedure getdatalabel(out l : TAsmLabel);
|
||||
{ generate an alternative (duplicate) symbol }
|
||||
@ -397,6 +398,11 @@ implementation
|
||||
inc(FNextLabelNr[alt_jump]);
|
||||
end;
|
||||
|
||||
procedure TAsmData.getglobaljumplabel(out l : TAsmLabel);
|
||||
begin
|
||||
l:=TAsmLabel.createglobal(AsmSymbolDict,name,FNextLabelNr[alt_jump],alt_jump);
|
||||
inc(FNextLabelNr[alt_jump]);
|
||||
end;
|
||||
|
||||
procedure TAsmData.getdatalabel(out l : TAsmLabel);
|
||||
begin
|
||||
|
@ -877,7 +877,10 @@ implementation
|
||||
function tcglabelnode.getasmlabel : tasmlabel;
|
||||
begin
|
||||
if not(assigned(asmlabel)) then
|
||||
current_asmdata.getjumplabel(asmlabel);
|
||||
if labsym.nonlocal then
|
||||
current_asmdata.getglobaljumplabel(asmlabel)
|
||||
else
|
||||
current_asmdata.getjumplabel(asmlabel);
|
||||
result:=asmlabel
|
||||
end;
|
||||
|
||||
|
@ -1700,6 +1700,8 @@ implementation
|
||||
consume(_COLON);
|
||||
if tlabelsym(srsym).defined then
|
||||
Message(sym_e_label_already_defined);
|
||||
if symtablestack.top.symtablelevel<>srsymtable.symtablelevel then
|
||||
tlabelsym(srsym).nonlocal:=true;
|
||||
tlabelsym(srsym).defined:=true;
|
||||
p1:=clabelnode.create(nil,tlabelsym(srsym));
|
||||
tlabelsym(srsym).code:=p1;
|
||||
|
@ -1419,13 +1419,18 @@ Begin
|
||||
case sym.typ of
|
||||
labelsym :
|
||||
begin
|
||||
if symtablestack.top.symtablelevel<>srsymtable.symtablelevel then
|
||||
Tlabelsym(sym).nonlocal:=true;
|
||||
if not(assigned(tlabelsym(sym).asmblocklabel)) then
|
||||
current_asmdata.getjumplabel(tlabelsym(sym).asmblocklabel);
|
||||
if Tlabelsym(sym).nonlocal then
|
||||
current_asmdata.getglobaljumplabel(tlabelsym(sym).asmblocklabel)
|
||||
else
|
||||
current_asmdata.getjumplabel(tlabelsym(sym).asmblocklabel);
|
||||
hl:=tlabelsym(sym).asmblocklabel;
|
||||
if emit then
|
||||
tlabelsym(sym).defined:=true
|
||||
tlabelsym(sym).defined:=true
|
||||
else
|
||||
tlabelsym(sym).used:=true;
|
||||
tlabelsym(sym).used:=true;
|
||||
SearchLabel:=true;
|
||||
end;
|
||||
end;
|
||||
|
@ -51,7 +51,8 @@ interface
|
||||
|
||||
tlabelsym = class(tstoredsym)
|
||||
used,
|
||||
defined : boolean;
|
||||
defined,
|
||||
nonlocal : boolean;
|
||||
{ points to the matching node, only valid resultdef pass is run and
|
||||
the goto<->label relation in the node tree is created, should
|
||||
be a tnode }
|
||||
@ -390,6 +391,7 @@ implementation
|
||||
inherited create(labelsym,n);
|
||||
used:=false;
|
||||
defined:=false;
|
||||
nonlocal:=false;
|
||||
code:=nil;
|
||||
end;
|
||||
|
||||
@ -399,6 +401,7 @@ implementation
|
||||
inherited ppuload(labelsym,ppufile);
|
||||
code:=nil;
|
||||
used:=false;
|
||||
nonlocal:=false;
|
||||
defined:=true;
|
||||
end;
|
||||
|
||||
@ -420,7 +423,10 @@ implementation
|
||||
if not(defined) then
|
||||
begin
|
||||
defined:=true;
|
||||
current_asmdata.getjumplabel(asmblocklabel);
|
||||
if nonlocal then
|
||||
current_asmdata.getglobaljumplabel(asmblocklabel)
|
||||
else
|
||||
current_asmdata.getjumplabel(asmblocklabel);
|
||||
end;
|
||||
result:=asmblocklabel.name;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user