Explorar o código

* split the two error cases of tanonfunc25 into two different tests

Sven/Sarah Barth hai 1 ano
pai
achega
74833bda09
Modificáronse 2 ficheiros con 39 adicións e 5 borrados
  1. 0 5
      tests/test/tanonfunc25.pp
  2. 39 0
      tests/test/tanonfunc74.pp

+ 0 - 5
tests/test/tanonfunc25.pp

@@ -5,7 +5,6 @@ program tanonfunc25;
 {$mode objfpc}
 {$modeswitch anonymousfunctions}
 {$modeswitch functionreferences}
-{$modeswitch nestedprocvars}
 
 { verify that nested procedures aren't accessible from anonymous functions
   in the captured procedure }
@@ -24,13 +23,9 @@ procedure foo;
   begin
   end;
 
-type
-  TNested = procedure is nested;
-
 begin
   bar;
   baz(procedure begin bar end);
-  baz(procedure var n: TNested; begin n := @bar; end);
 end;
 
 begin

+ 39 - 0
tests/test/tanonfunc74.pp

@@ -0,0 +1,39 @@
+{ %FAIL }
+
+program tanonfunc74;
+
+{$mode objfpc}
+{$modeswitch anonymousfunctions}
+{$modeswitch functionreferences}
+{$modeswitch nestedprocvars}
+
+{ verify that nested procedures aren't accessible from anonymous functions
+  in the captured procedure }
+
+type
+  tproc = reference to procedure;
+
+procedure baz(p: tproc);
+begin
+  p();
+end;
+
+procedure foo;
+
+  procedure bar;
+  begin
+  end;
+
+type
+  TNested = procedure is nested;
+
+begin
+  bar;
+  baz(procedure var n: TNested; begin n := @bar; end);
+end;
+
+begin
+  foo;
+end.
+
+