* Calling tlabelsym.mangledname should not define the label. This was causing "already defined" errors if a label was referenced before it was defined.

+ Test.
+ Check duplicate labels in assembler blocks. This was impossible due to above bug and duplicate labels were detected only at assembling stage where no location information could be provided.

git-svn-id: trunk@27472 -
This commit is contained in:
sergei 2014-04-05 01:17:36 +00:00
parent e43791cf7c
commit adc8cdb5af
4 changed files with 34 additions and 3 deletions

1
.gitattributes vendored
View File

@ -10059,6 +10059,7 @@ tests/tbs/tb0465.pp svneol=native#text/plain
tests/tbs/tb0466.pp svneol=native#text/plain
tests/tbs/tb0467.pp svneol=native#text/plain
tests/tbs/tb0468.pp svneol=native#text/plain
tests/tbs/tb0468a.pas svneol=native#text/plain
tests/tbs/tb0469.pp svneol=native#text/plain
tests/tbs/tb0470.pp svneol=native#text/plain
tests/tbs/tb0471.pp svneol=native#text/plain

View File

@ -1513,7 +1513,11 @@ Begin
current_asmdata.getjumplabel(tlabelsym(sym).asmblocklabel);
hl:=tlabelsym(sym).asmblocklabel;
if emit then
tlabelsym(sym).defined:=true
begin
if tlabelsym(sym).defined then
Message(sym_e_label_already_defined);
tlabelsym(sym).defined:=true
end
else
tlabelsym(sym).used:=true;
SearchLabel:=true;

View File

@ -625,9 +625,8 @@ implementation
function tlabelsym.mangledname:TSymStr;
begin
if not(defined) then
if (asmblocklabel=nil) then
begin
defined:=true;
if nonlocal then
current_asmdata.getglobaljumplabel(asmblocklabel)
else

27
tests/tbs/tb0468a.pas Normal file
View File

@ -0,0 +1,27 @@
{ %OPT=-Sg }
procedure foo;
begin
end;
procedure test;
label
a,b,c,d;
const
x: array[0..3] of pointer=(@a,@b,@c,@d);
begin
foo;
a:
foo;
b:
foo;
c:
foo;
d:
foo;
end;
begin
end.