+ Added a test for: When {$mode delphi} and {$modeswitch nestedprocvars} it is allowed to assign a nested routine which does not use parentfp to a regular procvar. And then call this procvar without any side effects.

git-svn-id: trunk@47209 -
This commit is contained in:
yury 2020-10-26 17:53:40 +00:00
parent bf5b85e5e5
commit 438bba76b9
2 changed files with 40 additions and 0 deletions

1
.gitattributes vendored
View File

@ -15315,6 +15315,7 @@ 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/tnest4.pp svneol=native#text/plain
tests/test/tnest5.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

39
tests/test/tnest5.pp Normal file
View File

@ -0,0 +1,39 @@
{$mode delphi}
{$modeswitch nestedprocvars}
type
tfunc = function (a1,a2,a3,a4,a5,a6,a7,a8,a9: longint): longint;
procedure proc;
function nested(a1,a2,a3,a4,a5,a6,a7,a8,a9: longint): longint;
begin
result:=a1+a2+a8+a9;
end;
var
n: tfunc;
i: longint;
begin
i:=nested(1,2,3,4,5,6,7,8,9);
writeln(i);
if i<>20 then
begin
writeln('Invalid result.');
halt(1);
end;
n:=@nested;
i:=n(1,2,3,4,5,6,7,8,9);
writeln(i);
if i<>20 then
begin
writeln('Invalid result.');
halt(2);
end;
end;
begin
proc;
writeln('OK');
end.