Mike Stump | fa6ef18 | 2010-01-13 02:59:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -fblocks -verify %s |
| 2 | |
| 3 | int j; |
| 4 | void bar() { } |
| 5 | int 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 | |
| 17 | void 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 | |
| 33 | void 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 | } |