mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 12:20:19 +02:00
+ 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:
parent
bf5b85e5e5
commit
438bba76b9
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
39
tests/test/tnest5.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user