Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/attributediagnostic_nothrow.d(19): Error: function `attributediagnostic_nothrow.layer1` is not `nothrow`
5 fail_compilation/attributediagnostic_nothrow.d(20): which calls `layer0`
6 fail_compilation/attributediagnostic_nothrow.d(21): which calls `gc`
7 fail_compilation/attributediagnostic_nothrow.d(25): and executing an `asm` statement without a `nothrow` annotation makes it fail to infer `nothrow`
8 fail_compilation/attributediagnostic_nothrow.d(19): Error: function `attributediagnostic_nothrow.layer2` may throw but is marked as `nothrow`
9 fail_compilation/attributediagnostic_nothrow.d(41): Error: function `attributediagnostic_nothrow.gc1` is not `nothrow`
10 fail_compilation/attributediagnostic_nothrow.d(30): and `object.Exception` being thrown but not caught makes it fail to infer `nothrow`
11 fail_compilation/attributediagnostic_nothrow.d(42): Error: function `attributediagnostic_nothrow.gc2` is not `nothrow`
12 fail_compilation/attributediagnostic_nothrow.d(39): Error: function `D main` may throw but is marked as `nothrow`
13 ---
14 */
15
16 // Issue 17374 - Improve inferred attribute error message
17 // https://issues.dlang.org/show_bug.cgi?id=17374
18
19 auto layer2() nothrow { layer1(); }
20 auto layer1() { layer0(); }
21 auto layer0() { gc(); }
22
23 auto gc()
24 {
25 asm {}
26 }
27
28 auto gc1()
29 {
30 throw new Exception("msg");
31 }
32
33 auto fgc = function void() {throw new Exception("msg");};
34 auto gc2()
35 {
36 fgc();
37 }
38
39 void main() nothrow
40 {
41 gc1();
42 gc2();
43 }