blob: 205c39c6e2cc11f4d790936256d6ae02acc8335c [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:
33 live(),
34 halt(),
35 dead(); // expected-warning {{will never be executed}}
36
37 case 3:
Mike Stump823000c2010-01-15 23:33:51 +000038 live()
39 + halt();
40 dead(); // expected-warning {{will never be executed}}
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;
75 }
76}