Prechádzať zdrojové kódy

* more dup id fixes

git-svn-id: trunk@2465 -
peter 19 rokov pred
rodič
commit
b1c66a106e
4 zmenil súbory, kde vykonal 54 pridanie a 32 odobranie
  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 :
                begin
                  { classrefdef inherits from pointerdef }
-                 hpd:=tpointerdef(pd).pointertype.def;
+                 hpd:=tabstractpointerdef(pd).pointertype.def;
                  { still a forward def ? }
                  if hpd.deftype=forwarddef then
                   begin

+ 34 - 23
compiler/ptype.pas

@@ -248,33 +248,44 @@ implementation
     procedure single_type(var tt:ttype;isforwarddef:boolean);
        var
          t2 : ttype;
+         again : boolean;
        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;
 
     { reads a record declaration }

+ 1 - 1
compiler/scanner.pas

@@ -3365,7 +3365,7 @@ In case not, the value returned can be arbitrary.
                   begin
                     readchar;
                     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=_RKLAMMER) or (lasttoken=_RECKKLAMMER) or (lasttoken=_CARET) then
                      begin

+ 18 - 7
compiler/symtable.pas

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