blob: 528bba7d5e15032ebdf5ecacc8fc657afc0ad9b5 [file] [log] [blame]
Mike Stumpfa6ef182010-01-13 02:59:54 +00001// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -fblocks -verify %s
2
3int j;
4void bar() { }
5int test1() {
6 for (int i = 0;
7 i != 10;
8 ++i) { // expected-warning {{will never be executed}}
9 if (j == 23) // missing {}'s
10 bar();
11 return 1;
12 }
13 return 0;
14 return 1; // expected-warning {{will never be executed}}
15}
16
17void test2(int i) {
18 switch (i) {
19 case 0:
20 break;
21 bar(); // expected-warning {{will never be executed}}
22 case 2:
23 switch (i) {
24 default:
25 a: goto a;
26 }
27 bar(); // expected-warning {{will never be executed}}
28 }
29 b: goto b;
30 bar(); // expected-warning {{will never be executed}}
31}
32
33void test3() {
34 ^{ return;
35 bar(); // expected-warning {{will never be executed}}
36 }();
37 while (++j) {
38 continue;
39 bar(); // expected-warning {{will never be executed}}
40 }
41}