Browse Source

+ 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 -
yury 4 years ago
parent
commit
438bba76b9
2 changed files with 40 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 39 0
      tests/test/tnest5.pp

+ 1 - 0
.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

+ 39 - 0
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.