Mike Stump | 823000c | 2010-01-15 23:33:51 +0000 | [diff] [blame] | 1 | // RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value |
Mike Stump | 9a24dc1 | 2010-01-15 03:15:36 +0000 | [diff] [blame] | 2 | |
Mike Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 3 | int halt() __attribute__((noreturn)); |
| 4 | int live(); |
| 5 | int dead(); |
| 6 | |
Mike Stump | 9a24dc1 | 2010-01-15 03:15:36 +0000 | [diff] [blame] | 7 | void 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 Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 25 | |
| 26 | void test2() { |
| 27 | switch (live()) { |
| 28 | case 1: |
| 29 | halt(), |
| 30 | dead(); // expected-warning {{will never be executed}} |
| 31 | |
| 32 | case 2: |
Mike Stump | 55f988e | 2010-01-21 17:21:23 +0000 | [diff] [blame^] | 33 | live(), halt(), |
Mike Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 34 | dead(); // expected-warning {{will never be executed}} |
| 35 | |
| 36 | case 3: |
Mike Stump | 823000c | 2010-01-15 23:33:51 +0000 | [diff] [blame] | 37 | live() |
Mike Stump | 55f988e | 2010-01-21 17:21:23 +0000 | [diff] [blame^] | 38 | + // expected-warning {{will never be executed}} |
| 39 | halt(); |
| 40 | dead(); |
Mike Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 41 | |
| 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 Stump | 55f988e | 2010-01-21 17:21:23 +0000 | [diff] [blame^] | 75 | case 7: |
| 76 | halt() |
| 77 | + // expected-warning {{will never be executed}} |
| 78 | dead(); |
| 79 | - // expected-warning {{will never be executed}} |
| 80 | halt(); |
Mike Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 81 | } |
| 82 | } |