* 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 -
This commit is contained in:
svenbarth 2017-06-09 15:46:10 +00:00
parent eb9b4fb71f
commit dffe423b10
3 changed files with 51 additions and 4 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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);

40
tests/webtbs/tw31945.pp Normal file
View File

@ -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<T> = 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<LongInt>;
initialization
end.