From adc8cdb5af3d77c45bbf7c9e3642ac62587be521 Mon Sep 17 00:00:00 2001 From: sergei Date: Sat, 5 Apr 2014 01:17:36 +0000 Subject: [PATCH] * 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 - --- .gitattributes | 1 + compiler/rautils.pas | 6 +++++- compiler/symsym.pas | 3 +-- tests/tbs/tb0468a.pas | 27 +++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tests/tbs/tb0468a.pas diff --git a/.gitattributes b/.gitattributes index 8c6030c588..df3d0ff097 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/compiler/rautils.pas b/compiler/rautils.pas index 334aad6030..ae6f6d46e1 100644 --- a/compiler/rautils.pas +++ b/compiler/rautils.pas @@ -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; diff --git a/compiler/symsym.pas b/compiler/symsym.pas index 02dbae09dd..7c5e434761 100644 --- a/compiler/symsym.pas +++ b/compiler/symsym.pas @@ -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 diff --git a/tests/tbs/tb0468a.pas b/tests/tbs/tb0468a.pas new file mode 100644 index 0000000000..adbebc8ca6 --- /dev/null +++ b/tests/tbs/tb0468a.pas @@ -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. +