From d8b82e0ba56fa5617b3d2f8848d2a5fb672f0041 Mon Sep 17 00:00:00 2001 From: joost Date: Fri, 9 Oct 2015 16:38:40 +0000 Subject: [PATCH] --- 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 - --- .gitattributes | 1 + compiler/ptype.pas | 27 +++++++++++++++++++++++++-- tests/webtbs/tw28674.pp | 17 +++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tests/webtbs/tw28674.pp diff --git a/.gitattributes b/.gitattributes index 90d571e115..3023fe4415 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14284,6 +14284,7 @@ tests/webtbs/tw2853d.pp svneol=native#text/plain tests/webtbs/tw2853e.pp svneol=native#text/plain tests/webtbs/tw2859.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/tw2883.pp svneol=native#text/plain tests/webtbs/tw2885.pp svneol=native#text/plain diff --git a/compiler/ptype.pas b/compiler/ptype.pas index f1d92d5f0d..80203e60a8 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -122,11 +122,13 @@ implementation procedure resolve_forward_types; var i: longint; + tmp, hpd, def : tdef; srsym : tsym; srsymtable : TSymtable; hs : string; + fileinfo : tfileposinfo; begin for i:=0 to current_module.checkforwarddefs.Count-1 do begin @@ -152,6 +154,20 @@ implementation if assigned(srsym) and (srsym.typ=typesym) then 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; { avoid wrong unused warnings web bug 801 PM } inc(ttypesym(srsym).refs); @@ -171,10 +187,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 diff --git a/tests/webtbs/tw28674.pp b/tests/webtbs/tw28674.pp new file mode 100644 index 0000000000..6fc1c880d7 --- /dev/null +++ b/tests/webtbs/tw28674.pp @@ -0,0 +1,17 @@ +{ %NORUN } + +program tw28674; + +{$mode objfpc} + +type + generic node = object + data: T; + link: ^node; + end; + + tintnode = specialize node; + +begin + +end.