Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/test16365.d

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/test16365.d(20): Error: taking address of member `f1` without `this` reference is not allowed in a `@safe` function
5 fail_compilation/test16365.d(22): Error: cannot implicitly convert expression `&f2` of type `void delegate() pure nothrow @nogc @safe` to `void function() @safe`
6 fail_compilation/test16365.d(27): Error: using `dg.funcptr` is not allowed in a `@safe` function
7 ---
8 */
9
10 // https://issues.dlang.org/show_bug.cgi?id=16365
11
12 struct S
13 {
14 void f1() @safe { }
15 }
16
17 void main() @safe
18 {
19 void function() @safe f;
20 f = &S.f1;
21 void f2() @safe { }
22 f = &f2;
23
24 void delegate() @safe dg;
25 S s;
26 dg = &s.f1;
27 f = dg.funcptr;
28 }