Browse Source

* fixed bug #248

peter 26 years ago
parent
commit
d2fd1ea874
2 changed files with 47 additions and 5 deletions
  1. 1 1
      bugs/readme.txt
  2. 46 4
      compiler/symtable.pas

+ 1 - 1
bugs/readme.txt

@@ -328,6 +328,7 @@ Fixed bugs:
   bug0280.pp   problem with object finalization.                    OK 0.99.13 (FK)
   bug0282.pp   long mangledname problem with -Aas                   OK 0.99.13 (PFV)
   bug0283.pp   bug in constant char comparison evaluation           OK 0.99.13 (PFV)
+  bug0284.pp   wrong file position with dup id in other unit        OK 0.99.13 (PFV)
   bug0285.pp   Asm, TYPE not support in intel mode                  OK 0.99.13 (PFV)
   bug0286.pp   #$08d not allowed as Char constant                   OK 0.99.13 (PFV)
   bug0287.pp   (true > false) not supported                         OK 0.99.13 (PFV)
@@ -376,4 +377,3 @@ bug0275.pp   too many warnings
 bug0277.pp   typecasting with const not possible
 bug0279.pp   crash with ansistring and new(^ansistring)
 bug0281.pp   dup id checking with property is wrong
-bug0284.pp   wrong file position with dup id in other unit

+ 46 - 4
compiler/symtable.pas

@@ -376,6 +376,7 @@ unit symtable;
 
 {*** Misc ***}
     function  globaldef(const s : string) : pdef;
+    function  findunitsymtable(st:psymtable):psymtable;
     procedure duplicatesym(sym:psym);
 
 {*** Search ***}
@@ -547,6 +548,33 @@ implementation
       end;
 
 
+    function findunitsymtable(st:psymtable):psymtable;
+      begin
+        findunitsymtable:=nil;
+        repeat
+          if not assigned(st) then
+           internalerror(5566561);
+          case st^.symtabletype of
+            localsymtable,
+            parasymtable,
+            staticsymtable :
+              break;
+            globalsymtable,
+            unitsymtable :
+              begin
+                findunitsymtable:=st;
+                break;
+              end;
+            objectsymtable,
+            recordsymtable :
+              st:=st^.defowner^.owner;
+            else
+              internalerror(5566562);
+          end;
+        until false;
+      end;
+
+
    procedure setstring(var p : pchar;const s : string);
      begin
 {$ifndef Delphi}
@@ -566,10 +594,21 @@ implementation
 
 
      procedure duplicatesym(sym:psym);
+       var
+         st : psymtable;
        begin
          Message1(sym_e_duplicate_id,sym^.name);
-         with sym^.fileinfo do
-          Message2(sym_h_duplicate_id_where,current_module^.sourcefiles^.get_file_name(fileindex),tostr(line));
+         st:=findunitsymtable(sym^.owner);
+         if assigned(st) then
+          begin
+            with sym^.fileinfo do
+             begin
+               if st^.unitid=0 then
+                Message2(sym_h_duplicate_id_where,current_module^.sourcefiles^.get_file_name(fileindex),tostr(line))
+               else
+                Message2(sym_h_duplicate_id_where,'unit '+st^.name^,tostr(line));
+             end;
+          end;
        end;
 
 
@@ -1901,7 +1940,7 @@ implementation
 
         writesourcefiles;
         writeusedmacros;
-        
+
         writeusedunit;
 
       { write the objectfiles and libraries that come for this unit,
@@ -2353,7 +2392,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.44  1999-08-31 15:46:21  pierre
+  Revision 1.45  1999-09-08 08:05:44  peter
+    * fixed bug 248
+
+  Revision 1.44  1999/08/31 15:46:21  pierre
     * do_crc must be false for all browser stuff
     + tmacrosym defined_at_startup set in def_macro and set_macro