blob: bbebebcc9000e524fb80240e2b9d8df340698212 [file] [log] [blame]
Mike Stump823000c2010-01-15 23:33:51 +00001// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value
Mike Stump9a24dc12010-01-15 03:15:36 +00002
Mike Stump8eae0902010-01-15 23:17:13 +00003int halt() __attribute__((noreturn));
4int live();
5int dead();
6
Mike Stump9a24dc12010-01-15 03:15:36 +00007void test1() {
8 goto c;
9 d:
10 goto e; // expected-warning {{will never be executed}}
11 c: ;
12 int i;
13 return;
14 goto b; // expected-warning {{will never be executed}}
15 goto a; // expected-warning {{will never be executed}}
16 b:
17 i = 1;
18 a:
19 i = 2;
20 goto f;
21 e:
22 goto d;
23 f: ;
24}
Mike Stump8eae0902010-01-15 23:17:13 +000025
26void test2() {
27 switch (live()) {
28 case 1:
29 halt(),
30 dead(); // expected-warning {{will never be executed}}
31
32 case 2:
Mike Stump55f988e2010-01-21 17:21:23 +000033 live(), halt(),
Mike Stump8eae0902010-01-15 23:17:13 +000034 dead(); // expected-warning {{will never be executed}}
35
36 case 3:
Mike Stump823000c2010-01-15 23:33:51 +000037 live()
Mike Stump55f988e2010-01-21 17:21:23 +000038 + // expected-warning {{will never be executed}}
39 halt();
40 dead();
Mike Stump8eae0902010-01-15 23:17:13 +000041
42 case 4:
43 a4:
44 live(),
45 halt();
46 goto a4; // expected-warning {{will never be executed}}
47
48 case 5:
49 goto a5;
50 c5:
51 dead(); // expected-warning {{will never be executed}}
52 goto b5;
53 a5:
54 live(),
55 halt();
56 b5:
57 goto c5;
58
59 case 6:
60 if (live())
61 goto e6;
62 live(),
63 halt();
64 d6:
65 dead(); // expected-warning {{will never be executed}}
66 goto b6;
67 c6:
68 dead();
69 goto b6;
70 e6:
71 live(),
72 halt();
73 b6:
74 goto c6;
Mike Stump55f988e2010-01-21 17:21:23 +000075 case 7:
76 halt()
77 + // expected-warning {{will never be executed}}
78 dead();
79 - // expected-warning {{will never be executed}}
80 halt();
Mike Stump8eae0902010-01-15 23:17:13 +000081 }
82}