* correctly handle the genericdef being a procdef, otherwise no code will be generated (and no error either :/ )

+ added test

git-svn-id: trunk@43586 -
This commit is contained in:
svenbarth 2019-11-25 20:28:23 +00:00
parent 6a36bec296
commit ef6c9e930b
3 changed files with 55 additions and 3 deletions

1
.gitattributes vendored
View File

@ -12976,6 +12976,7 @@ tests/tbs/tb0661.pp svneol=native#text/plain
tests/tbs/tb0662.pp svneol=native#text/pascal
tests/tbs/tb0663.pp svneol=native#text/plain
tests/tbs/tb0664.pp svneol=native#text/pascal
tests/tbs/tb0665.pp svneol=native#text/pascal
tests/tbs/ub0060.pp svneol=native#text/plain
tests/tbs/ub0069.pp svneol=native#text/plain
tests/tbs/ub0119.pp svneol=native#text/plain

View File

@ -472,8 +472,21 @@ uses
errorrecovery:=false;
if (symname='') and
(not assigned(genericdef) or
not assigned(genericdef.typesym) or
(genericdef.typesym.typ<>typesym)) then
(
(genericdef.typ<>procdef) and
(
not assigned(genericdef.typesym) or
(genericdef.typesym.typ<>typesym)
)
) or
(
(genericdef.typ=procdef) and
(
not assigned(tprocdef(genericdef).procsym) or
(tprocdef(genericdef).procsym.typ<>procsym)
)
)
) then
begin
errorrecovery:=true;
result:=generrordef;
@ -592,7 +605,12 @@ uses
{ use the name of the symbol as procvars return a user friendly version
of the name }
if symname='' then
genname:=ttypesym(genericdef.typesym).realname
begin
if genericdef.typ=procdef then
genname:=tprocdef(genericdef).procsym.realname
else
genname:=ttypesym(genericdef.typesym).realname;
end
else
genname:=symname;

33
tests/tbs/tb0665.pp Normal file
View File

@ -0,0 +1,33 @@
program tb0665;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TTest = record
b: Boolean;
function Test(aArg: Pointer): Boolean; inline;
generic function Test<T>: Boolean; inline;
end;
function TTest.Test(aArg: Pointer): Boolean;
begin
b := True;
Result := True;
end;
generic function TTest.Test<T>: Boolean;
begin
Result := Test(Nil);
end;
var
t: TTest;
begin
t.b := False;
{ check for side effects to ensure that the code was correctly generated }
t.specialize Test<LongInt>;
if not t.b then
Halt(1);
Writeln('ok');
end.