From 66781b552609c5931d2fbf4398f005c35a118db0 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 28 Aug 2015 15:46:18 +0000 Subject: [PATCH] Fix for Mantis #28530. ptype.pas: * record_dec: if parse_generic is given set current_genericdef + added test git-svn-id: trunk@31437 - --- .gitattributes | 1 + compiler/ptype.pas | 7 +++---- tests/webtbs/tw28530.pp | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 tests/webtbs/tw28530.pp diff --git a/.gitattributes b/.gitattributes index e7c42df057..0580caa03f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14694,6 +14694,7 @@ tests/webtbs/tw28442.pp svneol=native#text/pascal tests/webtbs/tw28454.pp svneol=native#text/plain tests/webtbs/tw28475.pp svneol=native#text/plain tests/webtbs/tw2853.pp svneol=native#text/plain +tests/webtbs/tw28530.pp svneol=native#text/pascal tests/webtbs/tw2853a.pp svneol=native#text/plain tests/webtbs/tw2853b.pp svneol=native#text/plain tests/webtbs/tw2853c.pp svneol=native#text/plain diff --git a/compiler/ptype.pas b/compiler/ptype.pas index b73f97ce71..6934e98ec8 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -928,10 +928,7 @@ implementation include(current_structdef.defoptions,df_specialization); if assigned(old_current_structdef) and (df_generic in old_current_structdef.defoptions) then - begin - include(current_structdef.defoptions,df_generic); - current_genericdef:=current_structdef; - end; + include(current_structdef.defoptions,df_generic); insert_generic_parameter_types(current_structdef,genericdef,genericlist); { when we are parsing a generic already then this is a generic as @@ -939,6 +936,8 @@ implementation if old_parse_generic then include(current_structdef.defoptions, df_generic); parse_generic:=(df_generic in current_structdef.defoptions); + if parse_generic and not assigned(current_genericdef) then + current_genericdef:=current_structdef; { in non-Delphi modes we need a strict private symbol without type count and type parameters in the name to simply resolving } maybe_insert_generic_rename_symbol(n,genericlist); diff --git a/tests/webtbs/tw28530.pp b/tests/webtbs/tw28530.pp new file mode 100644 index 0000000000..1c5daa22a8 --- /dev/null +++ b/tests/webtbs/tw28530.pp @@ -0,0 +1,25 @@ +{ %NORUN } + +program tw28530; + +{$mode objfpc} + +type + generic TDistanceFunction = function (x,y : t) : Extended; + + generic PlanarCoordinate = record + x,y : t; + d : specialize TDistanceFunction; + end; + TScreenCoordinate = specialize PLanarCoordinate; + TDiscreteCoordinate = specialize PlanarCoordinate; + TRealCoordinate = specialize PlanarCoordinate; + + TScreenDistance = specialize TDistanceFunction; + TDiscreteDistance = specialize TDistanceFunction; + TRealDistance = specialize TDistanceFunction; + + generic TPointSet = array of specialize PlanarCoordinate; + +begin +end.