d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / diag12829.d
blobaaedd0f72175a06ba085c37ce0dccead62502ae3
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag12829.d(15): Error: function `diag12829.test1` is `@nogc` yet allocates closure for `test1()` with the GC
5 fail_compilation/diag12829.d(18): delegate `diag12829.test1.__lambda2` closes over variable `x`
6 fail_compilation/diag12829.d(17): `x` declared here
7 fail_compilation/diag12829.d(22): function `diag12829.test1.bar` closes over variable `x`
8 fail_compilation/diag12829.d(17): `x` declared here
9 fail_compilation/diag12829.d(29): Error: function `diag12829.test2` is `@nogc` yet allocates closure for `test2()` with the GC
10 fail_compilation/diag12829.d(34): function `diag12829.test2.S.foo` closes over variable `x`
11 fail_compilation/diag12829.d(31): `x` declared here
12 ---
15 auto test1() @nogc
17 int x;
18 void delegate() @nogc foo = () {
19 int y = x;
22 void bar()
24 int y = x;
26 auto dg = &bar;
29 auto test2() @nogc
31 int x;
32 struct S
34 void foo()
36 int y = x;
39 return S();