Browse Source

* checking for dup id with para of methods fixed for delphi mode

peter 25 years ago
parent
commit
14d248a322
2 changed files with 21 additions and 28 deletions
  1. 10 22
      compiler/pdecl.pas
  2. 11 6
      compiler/symtable.pas

+ 10 - 22
compiler/pdecl.pas

@@ -74,7 +74,6 @@ unit pdecl;
         s       : string;
         storetokenpos : tfileposinfo;
         tt      : ttype;
-        hsym    : psym;
         hvs,
         vs      : Pvarsym;
         hs1,hs2 : string;
@@ -215,31 +214,17 @@ unit pdecl;
                      vs^.varspez:=varspez;
                    { we have to add this to avoid var param to be in registers !!!}
                      if (varspez in [vs_var,vs_const]) and push_addr_param(tt.def) then
-{$ifdef INCLUDEOK}
                        include(vs^.varoptions,vo_regable);
-{$else}
-                       vs^.varoptions:=vs^.varoptions+[vo_regable];
-{$endif}
 
-                   { search for duplicate ids in object members/methods    }
-                   { but only the current class, I don't know why ...      }
-                   { at least TP and Delphi do it in that way   (FK) }
-                     if assigned(procinfo^._class) and
-                        (lexlevel=normal_function_level) then
-                      begin
-                        hsym:=procinfo^._class^.symtable^.search(vs^.name);
-                        if assigned(hsym) then
-                         DuplicateSym(hsym);
-                      end;
+                   { insert the sym in the parasymtable }
+                     pprocdef(aktprocdef)^.parast^.insert(vs);
 
-                   { do we need a local copy? }
+                   { do we need a local copy? Then rename the varsym, do this after the
+                     insert so the dup id checking is done correctly }
                      if (varspez=vs_value) and
                         push_addr_param(tt.def) and
                         not(is_open_array(tt.def) or is_array_of_const(tt.def)) then
-                       vs^.setname('val'+vs^.name);
-
-                   { insert the sym in the parasymtable }
-                     pprocdef(aktprocdef)^.parast^.insert(vs);
+                       pprocdef(aktprocdef)^.parast^.rename(vs^.name,'val'+vs^.name);
 
                    { also need to push a high value? }
                      if inserthigh then
@@ -1218,7 +1203,10 @@ unit pdecl;
 end.
 {
   $Log$
-  Revision 1.183  2000-06-02 21:18:13  pierre
+  Revision 1.184  2000-06-09 21:34:40  peter
+    * checking for dup id with para of methods fixed for delphi mode
+
+  Revision 1.183  2000/06/02 21:18:13  pierre
    + set vo_is_exported for vars
 
   Revision 1.182  2000/06/01 19:14:09  peter
@@ -1305,4 +1293,4 @@ end.
   Revision 1.159  1999/10/01 10:05:42  peter
     + procedure directive support in const declarations, fixes bug 232
 
-}
+}

+ 11 - 6
compiler/symtable.pas

@@ -1819,6 +1819,8 @@ implementation
 
 
     procedure tsymtable.insert(sym:psym);
+      label
+         doinsert;
       var
          hp : psymtable;
          hsym : psym;
@@ -1930,10 +1932,10 @@ implementation
                 (not(sp_private in hsym^.symoptions) or
                  (hsym^.owner^.defowner^.owner^.symtabletype<>unitsymtable)) then
                 begin
-                   { delphi allows to reuse the names of properties }
-                   { in parameter lists of methods                  }
-                   if not((hsym^.typ=propertysym) and
-                     (m_delphi in aktmodeswitches)) then
+                   { delphi allows to reuse the names in a class, but not
+                     in object (tp7 compatible) }
+                   if not((m_delphi in aktmodeswitches) and
+                          (procinfo^._class^.is_class)) then
                     begin
                       DuplicateSym(hsym);
                       exit;
@@ -2925,7 +2927,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.96  2000-06-05 20:41:17  pierre
+  Revision 1.97  2000-06-09 21:34:40  peter
+    * checking for dup id with para of methods fixed for delphi mode
+
+  Revision 1.96  2000/06/05 20:41:17  pierre
     + support for NOT overloading
     + unsupported overloaded operators generate errors
 
@@ -3073,4 +3078,4 @@ end.
   Revision 1.56  1999/11/04 23:13:25  peter
     * moved unit alias support into ifdef
 
-}
+}