Browse Source

Fix for Mantis #28674.

ptype.pas, resolve_forward_types:
  * fix an access violation in case of inline pointer declarations
  * fix the check whether it's a valid use of a generic (parse_generic is useless here...)

+ added test

git-svn-id: trunk@31910 -
svenbarth 9 years ago
parent
commit
c25e7491e7
3 changed files with 26 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 10 2
      compiler/ptype.pas
  3. 15 0
      tests/webtbs/tw28674.pp

+ 1 - 0
.gitattributes

@@ -14752,6 +14752,7 @@ tests/webtbs/tw28593.pp svneol=native#text/plain
 tests/webtbs/tw28632.pp -text svneol=native#text/plain
 tests/webtbs/tw2865.pp svneol=native#text/plain
 tests/webtbs/tw28650.pp svneol=native#text/pascal
+tests/webtbs/tw28674.pp svneol=native#text/pascal
 tests/webtbs/tw28718a.pp svneol=native#text/plain
 tests/webtbs/tw28718b.pp svneol=native#text/plain
 tests/webtbs/tw28718c.pp svneol=native#text/plain

+ 10 - 2
compiler/ptype.pas

@@ -127,6 +127,7 @@ implementation
         srsym  : tsym;
         srsymtable : TSymtable;
         hs : string;
+        fileinfo : tfileposinfo;
       begin
         for i:=0 to current_module.checkforwarddefs.Count-1 do
           begin
@@ -171,10 +172,17 @@ implementation
                                   the case for generics defined in non-Delphi
                                   modes }
                                 tstoreddef(ttypesym(srsym).typedef).is_generic and
-                                not parse_generic
+                                not defs_belong_to_same_generic(def,ttypesym(srsym).typedef)
                               )
                             ) 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
                      else
                       begin

+ 15 - 0
tests/webtbs/tw28674.pp

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