]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/testsuite/gdc.test/fail_compilation/diag15411.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / diag15411.d
index bc77d81a8baff8f0ef645bc02da17e4a674d6e4e..8b18c19d0276f58fa3d7ff8438356bb6511b976e 100644 (file)
@@ -2,8 +2,12 @@
 /*
 TEST_OUTPUT:
 ---
-fail_compilation/diag15411.d(13): Error: function diag15411.test15411.__funcliteral1 cannot access frame of function diag15411.test15411
-fail_compilation/diag15411.d(14): Error: function diag15411.test15411.__funcliteral2 cannot access frame of function diag15411.test15411
+fail_compilation/diag15411.d(17): Error: function `diag15411.test15411.__funcliteral2` cannot access variable `i` in frame of function `diag15411.test15411`
+fail_compilation/diag15411.d(16):        `i` declared here
+fail_compilation/diag15411.d(18): Error: function `diag15411.test15411.__funcliteral4` cannot access variable `i` in frame of function `diag15411.test15411`
+fail_compilation/diag15411.d(16):        `i` declared here
+fail_compilation/diag15411.d(26): Error: `static` function `diag15411.testNestedFunction.myFunc2` cannot access function `myFunc1` in frame of function `diag15411.testNestedFunction`
+fail_compilation/diag15411.d(25):        `myFunc1` declared here
 ---
 */
 
@@ -13,3 +17,11 @@ void test15411()
     auto j = (function() { return i; })();
     auto f =  function() { return i; };
 }
+
+void testNestedFunction ()
+{
+    int i = 42;
+
+    void myFunc1() { assert(i == 42); }
+    static void myFunc2 () { myFunc1(); }
+}