blob: 01b36de5712de2936acf997cfdd43c5a3bd6d635 [file] [log] [blame]
Mike Stump4c45aa12010-01-21 15:20:48 +00001// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value
2
Mike Stump55f988e2010-01-21 17:21:23 +00003int &halt() __attribute__((noreturn));
4int &live();
Mike Stump4c45aa12010-01-21 15:20:48 +00005int dead();
6int liveti() throw(int);
7int (*livetip)() throw(int);
8
9int test1() {
10 try {
11 live();
12 } catch (int i) {
13 live();
14 }
15 return 1;
16}
17
18void test2() {
19 try {
20 live();
21 } catch (int i) {
22 live();
23 }
24 try {
25 liveti();
26 } catch (int i) {
27 live();
28 }
29 try {
30 livetip();
31 } catch (int i) {
32 live();
33 }
34 throw 1;
35 dead(); // expected-warning {{will never be executed}}
36}
Mike Stump55f988e2010-01-21 17:21:23 +000037
38
39void test3() {
40 halt()
41 --; // expected-warning {{will never be executed}}
Mike Stumpe5fba702010-01-21 19:44:04 +000042 halt()
Mike Stump2d6ceab2010-01-21 22:12:18 +000043 ? // expected-warning {{will never be executed}}
Mike Stumpe5fba702010-01-21 19:44:04 +000044 dead() : dead();
Mike Stump2d6ceab2010-01-21 22:12:18 +000045 live(),
46 float // expected-warning {{will never be executed}}
47 (halt());
Mike Stump55f988e2010-01-21 17:21:23 +000048}
Mike Stumpb5c77552010-01-21 23:15:53 +000049
50void test4() {
51 struct S {
52 int mem;
53 } s;
54 S &foor();
Zhongxing Xu91071662010-02-24 02:19:28 +000055 halt(), foor()// expected-warning {{will never be executed}}
56 .mem;
Mike Stumpb5c77552010-01-21 23:15:53 +000057}
58
59void test5() {
60 struct S {
61 int mem;
62 } s;
63 S &foor() __attribute__((noreturn));
64 foor()
65 .mem; // expected-warning {{will never be executed}}
66}
67
68void test6() {
69 struct S {
70 ~S() { }
71 S(int i) { }
72 };
73 live(),
74 S // expected-warning {{will never be executed}}
75 (halt());
76}