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