Debian Codegraph @

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

raw
1 // REQUIRED_ARGS: -o-
2
3 /*
4 TEST_OUTPUT:
5 ---
6 fail_compilation/fail11542.d(15): Error: `object.Exception` is thrown but not caught
7 fail_compilation/fail11542.d(12): Error: function `fail11542.test_success1` may throw but is marked as `nothrow`
8 fail_compilation/fail11542.d(25): Error: `object.Exception` is thrown but not caught
9 fail_compilation/fail11542.d(22): Error: function `fail11542.test_success3` may throw but is marked as `nothrow`
10 ---
11 */
12 void test_success1() nothrow
13 {
14 scope(success) {}
15 throw new Exception(""); // error
16 }
17 void test_success2() nothrow
18 {
19 scope(success) {}
20 throw new Error(""); // no error
21 }
22 void test_success3() nothrow
23 {
24 scope(success) assert(0);
25 throw new Exception(""); // error
26 }
27
28 /*
29 TEST_OUTPUT:
30 ---
31 fail_compilation/fail11542.d(38): Error: `object.Exception` is thrown but not caught
32 fail_compilation/fail11542.d(35): Error: function `fail11542.test_failure1` may throw but is marked as `nothrow`
33 ---
34 */
35 void test_failure1() nothrow
36 {
37 scope(failure) {}
38 throw new Exception(""); // error
39 }
40 void test_failure2() nothrow
41 {
42 scope(failure) {}
43 throw new Error(""); // no error
44 }
45 void est_failure3() nothrow
46 {
47 scope(failure) assert(0);
48 throw new Exception(""); // no error
49 }
50
51 /*
52 TEST_OUTPUT:
53 ---
54 fail_compilation/fail11542.d(61): Error: `object.Exception` is thrown but not caught
55 fail_compilation/fail11542.d(58): Error: function `fail11542.test_exit1` may throw but is marked as `nothrow`
56 ---
57 */
58 void test_exit1() nothrow
59 {
60 scope(exit) {}
61 throw new Exception(""); // error
62 }
63 void test_exit2() nothrow
64 {
65 scope(exit) {}
66 throw new Error(""); // no error
67 }
68 void test_exit3() nothrow
69 {
70 scope(exit) assert(0);
71 throw new Exception(""); // no error
72 }