Browse Source

* don't allow duplicate uses
* fix wrong circular dependency

peter 21 years ago
parent
commit
fa52c0e3a0
2 changed files with 20 additions and 8 deletions
  1. 7 2
      compiler/fmodule.pas
  2. 13 6
      compiler/pmodules.pas

+ 7 - 2
compiler/fmodule.pas

@@ -559,6 +559,7 @@ implementation
         linkothersharedlibs:=TLinkContainer.Create;
         linkothersharedlibs:=TLinkContainer.Create;
         uses_imports:=false;
         uses_imports:=false;
         do_compile:=false;
         do_compile:=false;
+        do_reload:=false;
         interface_compiled:=false;
         interface_compiled:=false;
         in_interface:=true;
         in_interface:=true;
         in_global:=true;
         in_global:=true;
@@ -570,8 +571,8 @@ implementation
           The following fields should not
           The following fields should not
           be reset:
           be reset:
            mainsource
            mainsource
-           loaded_from
            state
            state
+           loaded_from
            sources_avail
            sources_avail
         }
         }
       end;
       end;
@@ -691,7 +692,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.42  2003-11-23 17:23:49  peter
+  Revision 1.43  2003-12-08 22:33:43  peter
+    * don't allow duplicate uses
+    * fix wrong circular dependency
+
+  Revision 1.42  2003/11/23 17:23:49  peter
     * fixed memleak with derefdata
     * fixed memleak with derefdata
 
 
   Revision 1.41  2003/10/23 14:44:07  peter
   Revision 1.41  2003/10/23 14:44:07  peter

+ 13 - 6
compiler/pmodules.pas

@@ -511,9 +511,10 @@ implementation
                   end;
                   end;
                  pu:=tused_unit(pu.next);
                  pu:=tused_unit(pu.next);
                end;
                end;
-              { Need to register the unit? }
               if not assigned(hp2) then
               if not assigned(hp2) then
-                hp2:=registerunit(current_module,sorg,fn);
+                hp2:=registerunit(current_module,sorg,fn)
+              else
+                Message1(sym_e_duplicate_id,s);
               { Create unitsym, we need to use the name as specified, we
               { Create unitsym, we need to use the name as specified, we
                 can not use the modulename because that can be different
                 can not use the modulename because that can be different
                 when -Un is used }
                 when -Un is used }
@@ -929,17 +930,19 @@ implementation
          write_gdb_info;
          write_gdb_info;
 {$endIf Def New_GDB}
 {$endIf Def New_GDB}
 
 
+         { Our interface is compiled, generate CRC and switch to implementation }
          if not(cs_compilesystem in aktmoduleswitches) and
          if not(cs_compilesystem in aktmoduleswitches) and
             (Errorcount=0) then
             (Errorcount=0) then
            tppumodule(current_module).getppucrc;
            tppumodule(current_module).getppucrc;
+         current_module.in_interface:=false;
+         current_module.interface_compiled:=true;
 
 
-         { we have a new interface loaded, reload all flagged units }
+         { First reload all units depending on our interface, we need to do this
+           in the implementation part to prevent errorneous circular references }
          reload_flagged_units;
          reload_flagged_units;
 
 
          { Parse the implementation section }
          { Parse the implementation section }
          consume(_IMPLEMENTATION);
          consume(_IMPLEMENTATION);
-         current_module.in_interface:=false;
-         current_module.interface_compiled:=true;
 
 
          Message1(unit_u_loading_implementation_units,current_module.modulename^);
          Message1(unit_u_loading_implementation_units,current_module.modulename^);
 
 
@@ -1422,7 +1425,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.133  2003-11-29 20:13:25  florian
+  Revision 1.134  2003-12-08 22:33:43  peter
+    * don't allow duplicate uses
+    * fix wrong circular dependency
+
+  Revision 1.133  2003/11/29 20:13:25  florian
     * fixed several pi_do_call problems
     * fixed several pi_do_call problems
 
 
   Revision 1.132  2003/10/29 19:48:51  peter
   Revision 1.132  2003/10/29 19:48:51  peter