Browse Source

* more dup id fixes

git-svn-id: trunk@2465 -
peter 19 years ago
parent
commit
b1c66a106e
4 changed files with 54 additions and 32 deletions
  1. 1 1
      compiler/pdecl.pas
  2. 34 23
      compiler/ptype.pas
  3. 1 1
      compiler/scanner.pas
  4. 18 7
      compiler/symtable.pas

+ 1 - 1
compiler/pdecl.pas

@@ -301,7 +301,7 @@ implementation
              classrefdef :
              classrefdef :
                begin
                begin
                  { classrefdef inherits from pointerdef }
                  { classrefdef inherits from pointerdef }
-                 hpd:=tpointerdef(pd).pointertype.def;
+                 hpd:=tabstractpointerdef(pd).pointertype.def;
                  { still a forward def ? }
                  { still a forward def ? }
                  if hpd.deftype=forwarddef then
                  if hpd.deftype=forwarddef then
                   begin
                   begin

+ 34 - 23
compiler/ptype.pas

@@ -248,33 +248,44 @@ implementation
     procedure single_type(var tt:ttype;isforwarddef:boolean);
     procedure single_type(var tt:ttype;isforwarddef:boolean);
        var
        var
          t2 : ttype;
          t2 : ttype;
+         again : boolean;
        begin
        begin
-          case token of
-            _STRING:
-              string_dec(tt);
+         repeat
+           again:=false;
+             case token of
+               _STRING:
+                 string_dec(tt);
 
 
-            _FILE:
-              begin
-                 consume(_FILE);
-                 if token=_OF then
-                   begin
-                      consume(_OF);
-                      single_type(t2,false);
-                      tt.setdef(tfiledef.createtyped(t2));
-                   end
-                 else
-                   tt:=cfiletype;
-              end;
+               _FILE:
+                 begin
+                    consume(_FILE);
+                    if try_to_consume(_OF) then
+                      begin
+                         single_type(t2,false);
+                         tt.setdef(tfiledef.createtyped(t2));
+                      end
+                    else
+                      tt:=cfiletype;
+                 end;
 
 
-            _ID:
-              id_type(tt,isforwarddef);
+               _ID:
+                 begin
+                   if try_to_consume(_SPECIALIZE) then
+                     begin
+                       block_type:=bt_specialize;
+                       again:=true;
+                     end
+                   else
+                     id_type(tt,isforwarddef);
+                 end;
 
 
-            else
-              begin
-                message(type_e_type_id_expected);
-                tt:=generrortype;
-              end;
-         end;
+               else
+                 begin
+                   message(type_e_type_id_expected);
+                   tt:=generrortype;
+                 end;
+            end;
+        until not again;
       end;
       end;
 
 
     { reads a record declaration }
     { reads a record declaration }

+ 1 - 1
compiler/scanner.pas

@@ -3365,7 +3365,7 @@ In case not, the value returned can be arbitrary.
                   begin
                   begin
                     readchar;
                     readchar;
                     c:=upcase(c);
                     c:=upcase(c);
-                    if (block_type=bt_type) or
+                    if (block_type in [bt_type,bt_specialize]) or
                        (lasttoken=_ID) or (lasttoken=_NIL) or
                        (lasttoken=_ID) or (lasttoken=_NIL) or
                        (lasttoken=_RKLAMMER) or (lasttoken=_RECKKLAMMER) or (lasttoken=_CARET) then
                        (lasttoken=_RKLAMMER) or (lasttoken=_RECKKLAMMER) or (lasttoken=_CARET) then
                      begin
                      begin

+ 18 - 7
compiler/symtable.pas

@@ -1069,14 +1069,17 @@ implementation
       var
       var
          hsym : tsym;
          hsym : tsym;
       begin
       begin
-         result:=inherited checkduplicate(sym);
-         if result then
+         result:=false;
+         if not assigned(defowner) then
+           internalerror(200602061);
+
+         if (m_duplicate_names in aktmodeswitches) and
+            (sym.typ in [paravarsym,localvarsym]) then
            exit;
            exit;
 
 
          { check for duplicate field, parameter or local names
          { check for duplicate field, parameter or local names
            also in inherited classes }
            also in inherited classes }
          if (sym.typ in [fieldvarsym,paravarsym,localvarsym]) and
          if (sym.typ in [fieldvarsym,paravarsym,localvarsym]) and
-            assigned(defowner) and
             (
             (
              not(m_delphi in aktmodeswitches) or
              not(m_delphi in aktmodeswitches) or
              is_object(tdef(defowner))
              is_object(tdef(defowner))
@@ -1090,6 +1093,12 @@ implementation
                   DuplicateSym(sym,hsym);
                   DuplicateSym(sym,hsym);
                   result:=true;
                   result:=true;
                 end;
                 end;
+           end
+         else
+           begin
+             result:=inherited checkduplicate(sym);
+             if result then
+               exit;
            end;
            end;
       end;
       end;
 
 
@@ -1173,7 +1182,8 @@ implementation
         { check objectsymtable, skip this for funcret sym because
         { check objectsymtable, skip this for funcret sym because
           that will always be positive because it has the same name
           that will always be positive because it has the same name
           as the procsym }
           as the procsym }
-        if not is_funcret_sym(sym) and
+        if not(m_duplicate_names in aktmodeswitches) and
+           not is_funcret_sym(sym) and
            (defowner.deftype=procdef) and
            (defowner.deftype=procdef) and
            assigned(tprocdef(defowner)._class) and
            assigned(tprocdef(defowner)._class) and
            (tprocdef(defowner).owner.defowner=tprocdef(defowner)._class) then
            (tprocdef(defowner).owner.defowner=tprocdef(defowner)._class) then
@@ -1198,9 +1208,10 @@ implementation
         result:=inherited checkduplicate(sym);
         result:=inherited checkduplicate(sym);
         if result then
         if result then
           exit;
           exit;
-        if (defowner.deftype=procdef) and
-            assigned(tprocdef(defowner)._class) and
-            (tprocdef(defowner).owner.defowner=tprocdef(defowner)._class) then
+        if not(m_duplicate_names in aktmodeswitches) and
+           (defowner.deftype=procdef) and
+           assigned(tprocdef(defowner)._class) and
+           (tprocdef(defowner).owner.defowner=tprocdef(defowner)._class) then
           result:=tprocdef(defowner)._class.symtable.checkduplicate(sym);
           result:=tprocdef(defowner)._class.symtable.checkduplicate(sym);
       end;
       end;