Explorar el Código

* give an error when trying to take address of a global label declared in
another scope instead of crashing (mantis #21078)

git-svn-id: trunk@20508 -

Jonas Maebe hace 13 años
padre
commit
5c56b1bc3d
Se han modificado 3 ficheros con 20 adiciones y 1 borrados
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/nld.pas
  3. 14 0
      tests/webtbf/tw21078.pp

+ 1 - 0
.gitattributes

@@ -11316,6 +11316,7 @@ tests/webtbf/tw20721b.pp svneol=native#text/pascal
 tests/webtbf/tw20721c.pp svneol=native#text/pascal
 tests/webtbf/tw20721c.pp svneol=native#text/pascal
 tests/webtbf/tw20907.pp svneol=native#text/plain
 tests/webtbf/tw20907.pp svneol=native#text/plain
 tests/webtbf/tw20907a.pp svneol=native#text/plain
 tests/webtbf/tw20907a.pp svneol=native#text/plain
+tests/webtbf/tw21078.pp svneol=native#text/plain
 tests/webtbf/tw21087.pp svneol=native#text/plain
 tests/webtbf/tw21087.pp svneol=native#text/plain
 tests/webtbf/tw2128.pp svneol=native#text/plain
 tests/webtbf/tw2128.pp svneol=native#text/plain
 tests/webtbf/tw2129.pp svneol=native#text/plain
 tests/webtbf/tw2129.pp svneol=native#text/plain

+ 5 - 1
compiler/nld.pas

@@ -425,7 +425,11 @@ implementation
                      end;
                      end;
                 end;
                 end;
            labelsym :
            labelsym :
-             ;
+             begin
+               if not assigned(tlabelsym(symtableentry).asmblocklabel) and
+                  not assigned(tlabelsym(symtableentry).code) then
+                 Message(parser_e_label_outside_proc);
+             end
            else
            else
              internalerror(200104143);
              internalerror(200104143);
          end;
          end;

+ 14 - 0
tests/webtbf/tw21078.pp

@@ -0,0 +1,14 @@
+{ %fail }
+
+{$goto on}
+label x;
+var p:pointer;
+
+procedure Foo();
+begin
+  x:
+end;
+
+begin
+	p:=@x;
+end.