Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/attributediagnostic.d(21): Error: `@safe` function `attributediagnostic.layer2` cannot call `@system` function `attributediagnostic.layer1`
5 fail_compilation/attributediagnostic.d(23): which calls `layer0`
6 fail_compilation/attributediagnostic.d(25): which calls `system`
7 fail_compilation/attributediagnostic.d(27): and executing an `asm` statement without `@trusted` annotation makes it fail to infer `@safe`
8 fail_compilation/attributediagnostic.d(22): `attributediagnostic.layer1` is declared here
9 fail_compilation/attributediagnostic.d(43): Error: `@safe` function `D main` cannot call `@system` function `attributediagnostic.system1`
10 fail_compilation/attributediagnostic.d(32): and cast from `uint` to `int*` makes it fail to infer `@safe`
11 fail_compilation/attributediagnostic.d(30): `attributediagnostic.system1` is declared here
12 fail_compilation/attributediagnostic.d(44): Error: `@safe` function `D main` cannot call `@system` function `attributediagnostic.system2`
13 fail_compilation/attributediagnostic.d(38): and calling `@system` `fsys` makes it fail to infer `@safe`
14 fail_compilation/attributediagnostic.d(36): `attributediagnostic.system2` is declared here
15 ---
16 */
17
18 // Issue 17374 - Improve inferred attribute error message
19 // https://issues.dlang.org/show_bug.cgi?id=17374
20
21 auto layer2() @safe { layer1(); }
22 auto layer1() { layer0(); }
23 auto layer0() { system(); }
24
25 auto system()
26 {
27 asm {}
28 }
29
30 auto system1()
31 {
32 int* x = cast(int*) 0xDEADBEEF;
33 }
34
35 auto fsys = function void() @system {};
36 auto system2()
37 {
38 fsys();
39 }
40
41 void main() @safe
42 {
43 system1();
44 system2();
45 }