From dffe423b10960f720cacac2b67e81c95bb4e3c82 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 9 Jun 2017 15:46:10 +0000 Subject: [PATCH] * fix for Mantis #31945: two fixes for nested routines inside generic methods a) correctly determine whether token recording is required or not (nested routines of generic routines don't need it) b) correctly determine whether the trailing ";" needs to be parsed (nested routines of generic routines need to) git-svn-id: trunk@36469 - --- .gitattributes | 1 + compiler/psub.pas | 14 ++++++++++---- tests/webtbs/tw31945.pp | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 tests/webtbs/tw31945.pp diff --git a/.gitattributes b/.gitattributes index 0ef2599dd3..e0b8701961 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15581,6 +15581,7 @@ tests/webtbs/tw3183a.pp svneol=native#text/plain tests/webtbs/tw3184.pp svneol=native#text/plain tests/webtbs/tw3185.pp svneol=native#text/plain tests/webtbs/tw3190.pp svneol=native#text/plain +tests/webtbs/tw31945.pp svneol=native#text/pascal tests/webtbs/tw3197.pp svneol=native#text/plain tests/webtbs/tw3207.pp svneol=native#text/plain tests/webtbs/tw3210.pp svneol=native#text/plain diff --git a/compiler/psub.pas b/compiler/psub.pas index 7be73f19b9..8b37fbb542 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -1877,10 +1877,12 @@ implementation entryswitches:=current_settings.localswitches; recordtokens:=procdef.is_generic or - ( - assigned(current_procinfo.procdef.struct) and - (df_generic in current_procinfo.procdef.struct.defoptions) - ); + ( + assigned(procdef.struct) and + (df_generic in procdef.struct.defoptions) and + assigned(procdef.owner) and + (procdef.owner.defowner=procdef.struct) + ); if recordtokens then begin @@ -2094,6 +2096,10 @@ implementation ( not assigned(current_procinfo.procdef.struct) or not (df_specialization in current_procinfo.procdef.struct.defoptions) + or not ( + assigned(current_procinfo.procdef.owner) and + (current_procinfo.procdef.owner.defowner=current_procinfo.procdef.struct) + ) ) then consume(_SEMICOLON); diff --git a/tests/webtbs/tw31945.pp b/tests/webtbs/tw31945.pp new file mode 100644 index 0000000000..66f18c35c0 --- /dev/null +++ b/tests/webtbs/tw31945.pp @@ -0,0 +1,40 @@ +{ Note: this is a vastly reduced variant of the example attached to bug report #31945 } + +unit tw31945; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils; + +type + { GprAvgLvlTreeNode } + + generic GprAvgLvlTreeNode = class + public + procedure ConsistencyCheck; virtual; + end; + +implementation + +{ GprAvgLvlTreeNode } + +procedure GprAvgLvlTreeNode.ConsistencyCheck; + + procedure E(Msg: string); + begin + raise Exception.Create('GprAvgLvlTreeNode.ConsistencyCheck: '+Msg); + end; + +begin + E('Hello World'); +end; + +var + t: specialize GprAvgLvlTreeNode; +initialization + +end. +