1 // REQUIRED_ARGS: -o- 2 // PERMUTE_ARGS: 3 4 bool cond; 5 6 /* 7 TEST_OUTPUT: 8 --- 9 fail_compilation/fail12809.d(19): Error: `object.Exception` is thrown but not caught 10 fail_compilation/fail12809.d(16): Error: nothrow function `fail12809.test_finally1` may throw 11 fail_compilation/fail12809.d(35): Error: `object.Exception` is thrown but not caught 12 fail_compilation/fail12809.d(39): Error: `object.Exception` is thrown but not caught 13 fail_compilation/fail12809.d(32): Error: nothrow function `fail12809.test_finally3` may throw 14 --- 15 */ test_finally1()16void test_finally1() nothrow 17 { 18 try 19 throw new Exception(""); // error 20 finally 21 {} 22 } 23 test_finally2()24void test_finally2() nothrow 25 { 26 try 27 throw new Exception(""); // no error 28 finally 29 assert(0); // unconditional halt 30 } 31 test_finally3()32void test_finally3() nothrow 33 { 34 try 35 throw new Exception(""); // error 36 finally 37 { 38 if (cond) 39 throw new Exception(""); // error 40 assert(0); // conditional halt 41 } 42 } 43 44 /* 45 TEST_OUTPUT: 46 --- 47 fail_compilation/fail12809.d(59): Error: `object.Exception` is thrown but not caught 48 fail_compilation/fail12809.d(54): Error: nothrow function `fail12809.test_finally4` may throw 49 fail_compilation/fail12809.d(75): Error: `object.Exception` is thrown but not caught 50 fail_compilation/fail12809.d(79): Error: `object.Exception` is thrown but not caught 51 fail_compilation/fail12809.d(70): Error: nothrow function `fail12809.test_finally6` may throw 52 --- 53 */ test_finally4()54void test_finally4() nothrow 55 { 56 try 57 {} 58 finally 59 throw new Exception(""); // error 60 } 61 test_finally5()62void test_finally5() nothrow 63 { 64 try 65 assert(0); // unconditional halt 66 finally 67 throw new Exception(""); // no error 68 } 69 test_finally6()70void test_finally6() nothrow 71 { 72 try 73 { 74 if (cond) 75 throw new Exception(""); // error 76 assert(0); // conditional halt 77 } 78 finally 79 throw new Exception(""); // error 80 } 81