Przeglądaj źródła

--- Merging r31910 into '.':
U compiler/ptype.pas
A tests/webtbs/tw28674.pp
--- Recording mergeinfo for merge of r31910 into '.':
U .
--- Merging r31987 into '.':
U tests/webtbs/tw28674.pp
G compiler/ptype.pas
--- Recording mergeinfo for merge of r31987 into '.':
G .i

# revisions: 31910,31987

git-svn-id: branches/fixes_3_0@31995 -

joost 9 lat temu
rodzic
commit
d8b82e0ba5
3 zmienionych plików z 43 dodań i 2 usunięć
  1. 1 0
      .gitattributes
  2. 25 2
      compiler/ptype.pas
  3. 17 0
      tests/webtbs/tw28674.pp

+ 1 - 0
.gitattributes

@@ -14284,6 +14284,7 @@ tests/webtbs/tw2853d.pp svneol=native#text/plain
 tests/webtbs/tw2853e.pp svneol=native#text/plain
 tests/webtbs/tw2853e.pp svneol=native#text/plain
 tests/webtbs/tw2859.pp svneol=native#text/plain
 tests/webtbs/tw2859.pp svneol=native#text/plain
 tests/webtbs/tw2865.pp svneol=native#text/plain
 tests/webtbs/tw2865.pp svneol=native#text/plain
+tests/webtbs/tw28674.pp svneol=native#text/pascal
 tests/webtbs/tw2876.pp svneol=native#text/plain
 tests/webtbs/tw2876.pp svneol=native#text/plain
 tests/webtbs/tw2883.pp svneol=native#text/plain
 tests/webtbs/tw2883.pp svneol=native#text/plain
 tests/webtbs/tw2885.pp svneol=native#text/plain
 tests/webtbs/tw2885.pp svneol=native#text/plain

+ 25 - 2
compiler/ptype.pas

@@ -122,11 +122,13 @@ implementation
     procedure resolve_forward_types;
     procedure resolve_forward_types;
       var
       var
         i: longint;
         i: longint;
+        tmp,
         hpd,
         hpd,
         def : tdef;
         def : tdef;
         srsym  : tsym;
         srsym  : tsym;
         srsymtable : TSymtable;
         srsymtable : TSymtable;
         hs : string;
         hs : string;
+        fileinfo : tfileposinfo;
       begin
       begin
         for i:=0 to current_module.checkforwarddefs.Count-1 do
         for i:=0 to current_module.checkforwarddefs.Count-1 do
           begin
           begin
@@ -152,6 +154,20 @@ implementation
                      if assigned(srsym) and
                      if assigned(srsym) and
                         (srsym.typ=typesym) then
                         (srsym.typ=typesym) then
                       begin
                       begin
+                        if (sp_generic_dummy in srsym.symoptions) and
+                            not (ttypesym(srsym).typedef.typ=undefineddef) and
+                            assigned(def.owner.defowner) then
+                          begin
+                            { is the forward def part of a specialization? }
+                            tmp:=tdef(def.owner.defowner);
+                            while not tstoreddef(tmp).is_specialization and assigned(tmp.owner.defowner) do
+                              tmp:=tdef(tmp.owner.defowner);
+                            { if the genericdef of the specialization is the same as the
+                              def the dummy points to, then update the found symbol }
+                            if tstoreddef(tmp).is_specialization and
+                                (tstoreddef(tmp).genericdef=ttypesym(srsym).typedef) then
+                              srsym:=tstoreddef(tmp).typesym;
+                          end;
                         tabstractpointerdef(def).pointeddef:=ttypesym(srsym).typedef;
                         tabstractpointerdef(def).pointeddef:=ttypesym(srsym).typedef;
                         { avoid wrong unused warnings web bug 801 PM }
                         { avoid wrong unused warnings web bug 801 PM }
                         inc(ttypesym(srsym).refs);
                         inc(ttypesym(srsym).refs);
@@ -171,10 +187,17 @@ implementation
                                   the case for generics defined in non-Delphi
                                   the case for generics defined in non-Delphi
                                   modes }
                                   modes }
                                 tstoreddef(ttypesym(srsym).typedef).is_generic and
                                 tstoreddef(ttypesym(srsym).typedef).is_generic and
-                                not parse_generic
+                                not defs_belong_to_same_generic(def,ttypesym(srsym).typedef)
                               )
                               )
                             ) then
                             ) then
-                          MessagePos(def.typesym.fileinfo,parser_e_no_generics_as_types);
+                          begin
+                            if assigned(def.typesym) then
+                              fileinfo:=def.typesym.fileinfo
+                            else
+                              { this is the case for inline pointer declarations }
+                              fileinfo:=srsym.fileinfo;
+                            MessagePos(fileinfo,parser_e_no_generics_as_types);
+                          end;
                       end
                       end
                      else
                      else
                       begin
                       begin

+ 17 - 0
tests/webtbs/tw28674.pp

@@ -0,0 +1,17 @@
+{ %NORUN }
+
+program tw28674;
+
+{$mode objfpc}
+
+type
+  generic node<T> = object
+    data: T;
+    link: ^node;
+  end;
+
+  tintnode = specialize node<int32>;
+
+begin
+
+end.