mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 11:39:24 +02:00
* 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:
parent
6a36bec296
commit
ef6c9e930b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -12976,6 +12976,7 @@ tests/tbs/tb0661.pp svneol=native#text/plain
|
|||||||
tests/tbs/tb0662.pp svneol=native#text/pascal
|
tests/tbs/tb0662.pp svneol=native#text/pascal
|
||||||
tests/tbs/tb0663.pp svneol=native#text/plain
|
tests/tbs/tb0663.pp svneol=native#text/plain
|
||||||
tests/tbs/tb0664.pp svneol=native#text/pascal
|
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/ub0060.pp svneol=native#text/plain
|
||||||
tests/tbs/ub0069.pp svneol=native#text/plain
|
tests/tbs/ub0069.pp svneol=native#text/plain
|
||||||
tests/tbs/ub0119.pp svneol=native#text/plain
|
tests/tbs/ub0119.pp svneol=native#text/plain
|
||||||
|
@ -472,8 +472,21 @@ uses
|
|||||||
errorrecovery:=false;
|
errorrecovery:=false;
|
||||||
if (symname='') and
|
if (symname='') and
|
||||||
(not assigned(genericdef) or
|
(not assigned(genericdef) or
|
||||||
|
(
|
||||||
|
(genericdef.typ<>procdef) and
|
||||||
|
(
|
||||||
not assigned(genericdef.typesym) or
|
not assigned(genericdef.typesym) or
|
||||||
(genericdef.typesym.typ<>typesym)) then
|
(genericdef.typesym.typ<>typesym)
|
||||||
|
)
|
||||||
|
) or
|
||||||
|
(
|
||||||
|
(genericdef.typ=procdef) and
|
||||||
|
(
|
||||||
|
not assigned(tprocdef(genericdef).procsym) or
|
||||||
|
(tprocdef(genericdef).procsym.typ<>procsym)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) then
|
||||||
begin
|
begin
|
||||||
errorrecovery:=true;
|
errorrecovery:=true;
|
||||||
result:=generrordef;
|
result:=generrordef;
|
||||||
@ -592,7 +605,12 @@ uses
|
|||||||
{ use the name of the symbol as procvars return a user friendly version
|
{ use the name of the symbol as procvars return a user friendly version
|
||||||
of the name }
|
of the name }
|
||||||
if symname='' then
|
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
|
else
|
||||||
genname:=symname;
|
genname:=symname;
|
||||||
|
|
||||||
|
33
tests/tbs/tb0665.pp
Normal file
33
tests/tbs/tb0665.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user