Browse Source

* fix checking for forwards in static symtable

peter 21 years ago
parent
commit
d4dcaeafaf
2 changed files with 67 additions and 55 deletions
  1. 39 29
      compiler/pmodules.pas
  2. 28 26
      compiler/psub.pas

+ 39 - 29
compiler/pmodules.pas

@@ -1016,7 +1016,7 @@ implementation
          { Parse the implementation section }
          { Parse the implementation section }
          if (m_mac in aktmodeswitches) and try_to_consume(_END) then
          if (m_mac in aktmodeswitches) and try_to_consume(_END) then
            has_impl:= false
            has_impl:= false
-         else 
+         else
            begin
            begin
              consume(_IMPLEMENTATION);
              consume(_IMPLEMENTATION);
              has_impl:= true;
              has_impl:= true;
@@ -1118,9 +1118,6 @@ implementation
          { the last char should always be a point }
          { the last char should always be a point }
          consume(_POINT);
          consume(_POINT);
 
 
-         { generate a list of threadvars }
-         InsertThreadvars;
-
          { Generate resoucestrings }
          { Generate resoucestrings }
          If ResourceStrings.ResStrCount>0 then
          If ResourceStrings.ResStrCount>0 then
           begin
           begin
@@ -1131,18 +1128,6 @@ implementation
              ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
              ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
           end;
           end;
 
 
-         if (Errorcount=0) then
-           begin
-             { test static symtable }
-             tstoredsymtable(st).allsymbolsused;
-             tstoredsymtable(st).allprivatesused;
-             current_module.allunitsused;
-           end;
-
-{$ifdef GDB}
-         write_gdb_info;
-{$endif GDB}
-
          if (Errorcount=0) then
          if (Errorcount=0) then
            begin
            begin
              { tests, if all (interface) forwards are resolved }
              { tests, if all (interface) forwards are resolved }
@@ -1151,6 +1136,16 @@ implementation
              tstoredsymtable(symtablestack).allprivatesused;
              tstoredsymtable(symtablestack).allprivatesused;
              { remove cross unit overloads }
              { remove cross unit overloads }
              tstoredsymtable(symtablestack).unchain_overloaded;
              tstoredsymtable(symtablestack).unchain_overloaded;
+
+             { test static symtable }
+             tstoredsymtable(st).allsymbolsused;
+             tstoredsymtable(st).allprivatesused;
+             tstoredsymtable(st).check_forwards;
+             tstoredsymtable(st).checklabels;
+             tstoredsymtable(st).unchain_overloaded;
+
+             { used units }
+             current_module.allunitsused;
            end;
            end;
 
 
          { leave when we got an error }
          { leave when we got an error }
@@ -1161,6 +1156,14 @@ implementation
             exit;
             exit;
           end;
           end;
 
 
+         { generate debuginfo }
+{$ifdef GDB}
+         write_gdb_info;
+{$endif GDB}
+
+         { generate a list of threadvars }
+         InsertThreadvars;
+
          { generate imports }
          { generate imports }
          if current_module.uses_imports then
          if current_module.uses_imports then
            importlib.generatelib;
            importlib.generatelib;
@@ -1388,26 +1391,30 @@ implementation
          { consume the last point }
          { consume the last point }
          consume(_POINT);
          consume(_POINT);
 
 
-{$ifdef GDB}
-         write_gdb_info;
-{$endif GDB}
-
-         { leave when we got an error }
-         if (Errorcount>0) and not status.skip_error then
-          begin
-            Message1(unit_f_errors_in_unit,tostr(Errorcount));
-            status.skip_error:=true;
-            exit;
-          end;
-
          if (Errorcount=0) then
          if (Errorcount=0) then
            begin
            begin
              { test static symtable }
              { test static symtable }
              tstoredsymtable(st).allsymbolsused;
              tstoredsymtable(st).allsymbolsused;
              tstoredsymtable(st).allprivatesused;
              tstoredsymtable(st).allprivatesused;
+             tstoredsymtable(st).check_forwards;
+             tstoredsymtable(st).checklabels;
+             tstoredsymtable(st).unchain_overloaded;
              current_module.allunitsused;
              current_module.allunitsused;
            end;
            end;
 
 
+         { leave when we got an error }
+         if (Errorcount>0) and not status.skip_error then
+           begin
+             Message1(unit_f_errors_in_unit,tostr(Errorcount));
+             status.skip_error:=true;
+             exit;
+           end;
+
+         { generate debuginfo }
+{$ifdef GDB}
+         write_gdb_info;
+{$endif GDB}
+
          { generate a list of threadvars }
          { generate a list of threadvars }
          InsertThreadvars;
          InsertThreadvars;
 
 
@@ -1473,7 +1480,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.151  2004-05-11 18:22:16  olle
+  Revision 1.152  2004-05-16 13:29:21  peter
+    * fix checking for forwards in static symtable
+
+  Revision 1.151  2004/05/11 18:22:16  olle
     * changed $mode mac to $mode macpas (macro defined should be FPC_MACPAS)
     * changed $mode mac to $mode macpas (macro defined should be FPC_MACPAS)
 
 
   Revision 1.150  2004/05/03 09:55:27  olle
   Revision 1.150  2004/05/03 09:55:27  olle

+ 28 - 26
compiler/psub.pas

@@ -959,39 +959,38 @@ implementation
          exitswitches:=aktlocalswitches;
          exitswitches:=aktlocalswitches;
          exitpos:=last_endtoken_filepos;
          exitpos:=last_endtoken_filepos;
 
 
-         if assigned(code) then
-           begin
-             { get a better entry point }
-             entrypos:=code.fileinfo;
-
-             { the procedure is now defined }
-             procdef.forwarddef:=false;
-
-             if (Errorcount=0) then
-               begin
-                 { add implicit entry and exit code }
-                 add_entry_exit_code;
-                 { check if forwards are resolved }
-                 tstoredsymtable(procdef.localst).check_forwards;
-                 { check if all labels are used }
-                 tstoredsymtable(procdef.localst).checklabels;
-                 { remove cross unit overloads }
-                 tstoredsymtable(procdef.localst).unchain_overloaded;
-               end;
+         { the procedure is now defined }
+         procdef.forwarddef:=false;
 
 
+         { Check for unused labels, forwards, symbols for procedures. Static
+           symtable is checked in pmodules }
+         if (Errorcount=0) and
+            (tstoredsymtable(procdef.localst).symtabletype<>staticsymtable) then
+           begin
+             { check if forwards are resolved }
+             tstoredsymtable(procdef.localst).check_forwards;
+             { check if all labels are used }
+             tstoredsymtable(procdef.localst).checklabels;
+             { remove cross unit overloads }
+             tstoredsymtable(procdef.localst).unchain_overloaded;
              { check for unused symbols, but only if there is no asm block }
              { check for unused symbols, but only if there is no asm block }
              if not(pi_uses_asm in flags) then
              if not(pi_uses_asm in flags) then
                begin
                begin
-                  { not for unit init, becuase the var can be used in finalize,
-                    it will be done in proc_unit }
-                  if not(procdef.proctypeoption in [potype_proginit,potype_unitinit,potype_unitfinalize]) then
-                     tstoredsymtable(procdef.localst).allsymbolsused;
-                  tstoredsymtable(procdef.parast).allsymbolsused;
+                 tstoredsymtable(procdef.localst).allsymbolsused;
+                 tstoredsymtable(procdef.parast).allsymbolsused;
                end;
                end;
+           end;
+
+         if assigned(code) then
+           begin
+             { get a better entry point }
+             entrypos:=code.fileinfo;
+
+             { add implicit entry and exit code }
+             add_entry_exit_code;
 
 
              { Finish type checking pass }
              { Finish type checking pass }
              do_resulttypepass(code);
              do_resulttypepass(code);
-
            end;
            end;
 
 
          { store a copy of the original tree for inline, for
          { store a copy of the original tree for inline, for
@@ -1346,7 +1345,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.187  2004-04-11 12:37:30  peter
+  Revision 1.188  2004-05-16 13:29:21  peter
+    * fix checking for forwards in static symtable
+
+  Revision 1.187  2004/04/11 12:37:30  peter
     * fix tree printing
     * fix tree printing
 
 
   Revision 1.186  2004/02/19 17:07:42  florian
   Revision 1.186  2004/02/19 17:07:42  florian