Forráskód Böngészése

This fixes Mantis #20851 .

For the solution symbols will now contain a "sp_explicitrename" flag if they
were created through a type rename. This is necessary, because we can't
decide whether a type is a renamed generic para which contains by default a
reference to the default undefined def. Using individual undefined defs will
lead to duplicate identifiers as they are created before a symtable was
pushed (thus they'll ba part of whatever symtable is at the top). 

+ symconst.pas, tsymoption:
        Add a new option "sp_explicitrename" which will be used to track type
        renames.
+ pdecl.pas, type_dec:
        Set the new flag if we're dealing with a type rename
* pexpr.pas, factor_read_id:
        If we have an undefined def that is also a rename then we assume that
        it's a rename of a generic parameter
* utils/ppudump.pp:
        Adjustment because of change to tsymoption
* utils/ppu.pp:
        Increase PPU version
+ added test

git-svn-id: trunk@20250 -
svenbarth 13 éve
szülő
commit
9cb16c950f

+ 1 - 0
.gitattributes

@@ -12173,6 +12173,7 @@ tests/webtbs/tw20796c.pp svneol=native#text/pascal
 tests/webtbs/tw20821.pp svneol=native#text/pascal
 tests/webtbs/tw20827.pp svneol=native#text/plain
 tests/webtbs/tw20836.pp svneol=native#text/pascal
+tests/webtbs/tw20851.pp svneol=native#text/pascal
 tests/webtbs/tw20872a.pp svneol=native#text/pascal
 tests/webtbs/tw20872b.pp svneol=native#text/pascal
 tests/webtbs/tw20872c.pp svneol=native#text/pascal

+ 4 - 1
compiler/pdecl.pas

@@ -582,7 +582,10 @@ implementation
               if assigned(hdef) then
                 begin
                   if assigned(hdef.typesym) then
-                    istyperenaming:=true;
+                    begin
+                      istyperenaming:=true;
+                      include(newtype.symoptions,sp_explicitrename);
+                    end;
                   if isunique then
                     begin
                       if is_objc_class_or_protocol(hdef) then

+ 6 - 1
compiler/pexpr.pas

@@ -2164,7 +2164,12 @@ implementation
                      (df_generic in current_structdef.defoptions) and
                      not (m_delphi in current_settings.modeswitches) and
                      (upper(srsym.realname)=copy(current_structdef.objname^,1,pos('$',current_structdef.objname^)-1))
-                   )) then
+                   )) and
+                   { it could be a rename of a generic para }
+                   { Note: if this generates false positives we'll need to
+                           include a "basesym" to tsym to track the original
+                           symbol }
+                   not (sp_explicitrename in srsym.symoptions) then
                  begin
                    identifier_not_found(orgstoredpattern);
                    srsym:=generrorsym;

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 
 const
-  CurrentPPUVersion = 144;
+  CurrentPPUVersion = 145;
 
 { buffer sizes }
   maxentrysize = 1024;

+ 3 - 1
compiler/symconst.pas

@@ -168,10 +168,12 @@ type
     sp_hint_experimental,
     sp_generic_para,
     sp_has_deprecated_msg,
-    sp_generic_dummy        { this is used for symbols that are generated when a
+    sp_generic_dummy,       { this is used for symbols that are generated when a
                               generic is encountered to ease inline
                               specializations, etc; those symbols can be
                               "overridden" with a completely different symbol }
+    sp_explicitrename       { this is used to keep track of type renames created
+                              by the user }
   );
   tsymoptions=set of tsymoption;
 

+ 2 - 1
compiler/utils/ppudump.pp

@@ -1075,7 +1075,8 @@ const
      (mask:sp_implicitrename;     str:'Implicit Rename'),
      (mask:sp_generic_para;       str:'Generic Parameter'),
      (mask:sp_has_deprecated_msg; str:'Has Deprecated Message'),
-     (mask:sp_generic_dummy;      str:'Generic Dummy')
+     (mask:sp_generic_dummy;      str:'Generic Dummy'),
+     (mask:sp_explicitrename;     str:'Explicit Rename')
   );
 var
   symoptions : tsymoptions;

+ 20 - 0
tests/webtbs/tw20851.pp

@@ -0,0 +1,20 @@
+program genimpl1;
+{$ifdef fpc}{$mode delphi}{$else}{$apptype console}{$endif}
+Type
+  tbwimagegen<T> = Class 
+                 Type
+
+                    BaseUnit = T;
+                 procedure alloc;
+                 end;
+
+
+procedure tbwimagegen<T>.alloc;
+var i,j : integer;
+begin
+  j:=sizeof(t);
+  i:=sizeof(baseunit);
+end;
+
+begin
+end.