浏览代码

* 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 -

sergei 11 年之前
父节点
当前提交
adc8cdb5af
共有 4 个文件被更改,包括 34 次插入3 次删除
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/rautils.pas
  3. 1 2
      compiler/symsym.pas
  4. 27 0
      tests/tbs/tb0468a.pas

+ 1 - 0
.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

+ 5 - 1
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;

+ 1 - 2
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

+ 27 - 0
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.
+