Kaynağa Gözat

* do check for non defined labels earlier to avoid ies in the cg

git-svn-id: trunk@6698 -
florian 18 yıl önce
ebeveyn
işleme
b8af065523
3 değiştirilmiş dosya ile 36 ekleme ve 1 silme
  1. 1 0
      .gitattributes
  2. 4 1
      compiler/pmodules.pas
  3. 31 0
      tests/tbf/tb0198.pp

+ 1 - 0
.gitattributes

@@ -5688,6 +5688,7 @@ tests/tbf/tb0194.pp svneol=native#text/plain
 tests/tbf/tb0195.pp svneol=native#text/plain
 tests/tbf/tb0196.pp svneol=native#text/plain
 tests/tbf/tb0197.pp svneol=native#text/plain
+tests/tbf/tb0198.pp svneol=native#text/plain
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain

+ 4 - 1
compiler/pmodules.pas

@@ -1359,6 +1359,10 @@ implementation
            if force_init_final then
              finalize_procinfo:=gen_implicit_initfinal(uf_finalize,current_module.localsymtable);
 
+         { all labels must be defined before generating code }
+         if Errorcount=0 then
+           tstoredsymtable(current_module.localsymtable).checklabels;
+
          { See remark in unit init/final }
          main_procinfo.generate_code;
          main_procinfo.resetprocdef;
@@ -1387,7 +1391,6 @@ implementation
              tstoredsymtable(current_module.localsymtable).allsymbolsused;
              tstoredsymtable(current_module.localsymtable).allprivatesused;
              tstoredsymtable(current_module.localsymtable).check_forwards;
-             tstoredsymtable(current_module.localsymtable).checklabels;
              tstoredsymtable(current_module.localsymtable).unchain_overloaded;
 
              current_module.allunitsused;

+ 31 - 0
tests/tbf/tb0198.pp

@@ -0,0 +1,31 @@
+{ %fail }
+var
+  i : longint;
+
+label
+  labelfor2,labelfor3,labelfor4;
+
+begin
+  case i of
+    1:
+      begin
+        writeln('1');
+        goto labelfor2;
+      end;
+    2:
+      begin
+        writeln('2');
+        goto labelfor3;
+      end;
+    3:
+      begin
+        writeln('3');
+        goto labelfor4;
+      end;
+    4:
+      begin
+      writeln('4');
+      end;
+  end;
+end.
+