From 438bba76b9d154b8d963b54f8d67721c39252009 Mon Sep 17 00:00:00 2001 From: yury Date: Mon, 26 Oct 2020 17:53:40 +0000 Subject: [PATCH] + 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 - --- .gitattributes | 1 + tests/test/tnest5.pp | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/test/tnest5.pp diff --git a/.gitattributes b/.gitattributes index eb11429001..984a22c556 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/tests/test/tnest5.pp b/tests/test/tnest5.pp new file mode 100644 index 0000000000..ac1d288bbf --- /dev/null +++ b/tests/test/tnest5.pp @@ -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.