Browse Source

+ Hint about unused unit
* Testop bug fixed !!
Now the operators are only applied if the unit is explicitly loaded

pierre 25 years ago
parent
commit
dbdb7ee667
3 changed files with 93 additions and 6 deletions
  1. 14 2
      compiler/pmodules.pas
  2. 8 1
      compiler/psub.pas
  3. 71 3
      compiler/symtable.pas

+ 14 - 2
compiler/pmodules.pas

@@ -785,6 +785,9 @@ unit pmodules;
                 end;
               hp:=pused_unit(hp^.next);
            end;
+{$ifndef DONOTCHAINOPERATORS}
+          symtablestack^.chainoperators;
+{$endif DONOTCHAINOPERATORS}
           aktprocsym:=oldprocsym;
       end;
 
@@ -1109,6 +1112,8 @@ unit pmodules;
             status.skip_error:=true;
             exit;
           end;
+         {else  in inteface its somatimes necessary even if unused
+          st^.allunitsused; }
 
 {$ifdef New_GDB}
          write_gdb_info;
@@ -1270,6 +1275,7 @@ unit pmodules;
          if (Errorcount=0) then
            begin
              st^.allsymbolsused;
+             st^.allunitsused;
              st^.allprivatesused;
            end;
 
@@ -1596,7 +1602,8 @@ unit pmodules;
          { test static symtable }
          if (Errorcount=0) then
            begin
-              st^.allsymbolsused;
+             st^.allsymbolsused;
+             st^.allunitsused;
              st^.allprivatesused;
            end;
 
@@ -1661,7 +1668,12 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.188  2000-04-14 08:15:05  pierre
+  Revision 1.189  2000-04-25 23:55:30  pierre
+    + Hint about unused unit
+    * Testop bug fixed !!
+      Now the operators are only applied if the unit is explicitly loaded
+
+  Revision 1.188  2000/04/14 08:15:05  pierre
    * close ppu file if errors
 
   Revision 1.187  2000/04/02 10:18:18  florian

+ 8 - 1
compiler/psub.pas

@@ -264,6 +264,7 @@ begin
      aktprocsym:=new(pprocsym,init(sp));
      { for operator we have only one definition for each overloaded
        operation }
+{$ifdef DONOTCHAINOPERATORS}
      if (options=potype_operator) then
        begin
           { the only problem is that nextoverloaded might not be in a unit
@@ -271,6 +272,7 @@ begin
           if assigned(overloaded_operators[optoken]) then
             aktprocsym^.definition:=overloaded_operators[optoken]^.definition;
        end;
+{$endif DONOTCHAINOPERATORS}
      symtablestack^.insert(aktprocsym);
    end;
 
@@ -2012,7 +2014,12 @@ end.
 
 {
   $Log$
-  Revision 1.57  2000-04-24 12:48:37  peter
+  Revision 1.58  2000-04-25 23:55:29  pierre
+    + Hint about unused unit
+    * Testop bug fixed !!
+      Now the operators are only applied if the unit is explicitly loaded
+
+  Revision 1.57  2000/04/24 12:48:37  peter
     * removed unused vars
 
   Revision 1.56  2000/03/31 22:56:47  pierre

+ 71 - 3
compiler/symtable.pas

@@ -219,6 +219,9 @@ unit symtable;
 {$ifdef CHAINPROCSYMS}
           procedure chainprocsyms;
 {$endif CHAINPROCSYMS}
+{$ifndef DONOTCHAINOPERATORS}
+          procedure chainoperators;
+{$endif DONOTCHAINOPERATORS}
           procedure load_browser;
           procedure write_browser;
 {$ifdef BrowserLog}
@@ -1095,8 +1098,11 @@ implementation
     procedure unitsymbolused(p : pnamedindexobject);
       begin
          if (psym(p)^.typ=unitsym) and
-            (punitsym(p)^.refs=0) then
-           comment(V_info,'Unit '+p^.name+' is not used');
+            (punitsym(p)^.refs=0) and
+            { do not claim for unit name itself !! }
+            (punitsym(p)^.unitsymtable^.symtabletype=unitsymtable) then
+           MessagePos2(psym(p)^.fileinfo,sym_n_unit_not_used,
+             p^.name,current_module^.modulename^);
       end;
 
     procedure varsymbolused(p : pnamedindexobject);
@@ -1242,6 +1248,63 @@ implementation
       end;
 {$endif}
 
+{$ifndef DONOTCHAINOPERATORS}
+    procedure tsymtable.chainoperators;
+      var
+        p : pprocsym;
+        t : ttoken;
+        def : pprocdef;
+        storesymtablestack : psymtable;
+      begin
+         storesymtablestack:=symtablestack;
+         symtablestack:=@self;
+         for t:=first_overloaded to last_overloaded do
+           begin
+              p:=nil;
+              def:=nil;
+              overloaded_operators[t]:=nil;
+              { each operator has a unique lowercased internal name PM }
+              while assigned(symtablestack) do
+                begin
+                  { search for same procsym in other units }
+                  getsym(overloaded_names[t],false);
+                  if assigned(srsym) then
+                    begin
+                       if (srsym^.typ<>procsym) or
+                          (pprocsym(srsym)^.definition^.proctypeoption<> potype_operator) then
+                         internalerror(12344321);
+                       if assigned(p) then
+                         begin
+{$ifdef CHAINPROCSYMS}
+                           p^.nextprocsym:=pprocsym(srsym);
+{$endif CHAINPROCSYMS}
+                           def^.nextoverloaded:=pprocsym(srsym)^.definition;
+                         end
+                       else
+                         overloaded_operators[t]:=pprocsym(srsym);
+                       p:=pprocsym(srsym);
+                       def:=p^.definition;
+                       while assigned(def^.nextoverloaded) and
+                         (def^.nextoverloaded^.owner=p^.owner) do
+                         def:=def^.nextoverloaded;
+                       def^.nextoverloaded:=nil;
+                       symtablestack:=srsymtable^.next;
+                    end
+                  else
+                    begin
+                      symtablestack:=nil;
+{$ifdef CHAINPROCSYMS}
+                      if assigned(p) then
+                        p^.nextprocsym:=nil;
+{$endif CHAINPROCSYMS}
+                    end;
+                end;
+              symtablestack:=@self;
+           end;
+         symtablestack:=storesymtablestack;
+      end;
+{$endif DONOTCHAINOPERATORS}
+
     procedure write_refs(sym : pnamedindexobject);
       begin
          psym(sym)^.write_references;
@@ -2816,7 +2879,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.84  2000-04-24 12:45:44  peter
+  Revision 1.85  2000-04-25 23:55:30  pierre
+    + Hint about unused unit
+    * Testop bug fixed !!
+      Now the operators are only applied if the unit is explicitly loaded
+
+  Revision 1.84  2000/04/24 12:45:44  peter
     * made overloaded_operators local per unit, but it still doesn't work
       correct