* Fixed the parentfp optimization for some cases when nested procvars are used.

git-svn-id: trunk@45664 -
This commit is contained in:
yury 2020-06-20 18:28:07 +00:00
parent cc23515927
commit c15b6f4516
3 changed files with 37 additions and 0 deletions

1
.gitattributes vendored
View File

@ -15228,6 +15228,7 @@ tests/test/tmt1.pp svneol=native#text/plain
tests/test/tmul1.pp svneol=native#text/pascal
tests/test/tnest1.pp svneol=native#text/plain
tests/test/tnest2.pp svneol=native#text/plain
tests/test/tnest3.pp svneol=native#text/plain
tests/test/tnoext1.pp svneol=native#text/plain
tests/test/tnoext2.pp svneol=native#text/plain
tests/test/tnoext3.pp svneol=native#text/plain

View File

@ -389,6 +389,9 @@ implementation
that the address needs to be returned }
resultdef:=fprocdef;
if is_nested_pd(fprocdef) and is_nested_pd(current_procinfo.procdef) then
current_procinfo.set_needs_parentfp(tprocdef(fprocdef.owner.defowner).parast.symtablelevel);
{ process methodpointer/framepointer }
if assigned(left) then
begin

33
tests/test/tnest3.pp Normal file
View File

@ -0,0 +1,33 @@
{$mode objfpc}
{$modeswitch nestedprocvars}
type
tnestedfunc = function (i: longint): longint is nested;
function test: longint;
var
i: longint;
function func3(aa: longint): longint;
begin
result:=i+aa;
end;
function func(aa: integer): integer;
var
nf: tnestedfunc;
begin
nf:=@func3;
result:=nf(aa);
end;
begin
i:=100;
result:=func(10);
end;
begin
if test <> 110 then
halt(1);
writeln('OK');
end.