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() { |
Mike Stump | 45db90d | 2010-01-21 17:31:41 +0000 | [diff] [blame] | 27 | int i; |
Mike Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 28 | switch (live()) { |
| 29 | case 1: |
| 30 | halt(), |
| 31 | dead(); // expected-warning {{will never be executed}} |
| 32 | |
| 33 | case 2: |
Mike Stump | 55f988e | 2010-01-21 17:21:23 +0000 | [diff] [blame] | 34 | live(), halt(), |
Mike Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 35 | dead(); // expected-warning {{will never be executed}} |
| 36 | |
| 37 | case 3: |
Mike Stump | 823000c | 2010-01-15 23:33:51 +0000 | [diff] [blame] | 38 | live() |
Mike Stump | 55f988e | 2010-01-21 17:21:23 +0000 | [diff] [blame] | 39 | + // expected-warning {{will never be executed}} |
| 40 | halt(); |
| 41 | dead(); |
Mike Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 42 | |
| 43 | case 4: |
| 44 | a4: |
| 45 | live(), |
| 46 | halt(); |
| 47 | goto a4; // expected-warning {{will never be executed}} |
| 48 | |
| 49 | case 5: |
| 50 | goto a5; |
| 51 | c5: |
| 52 | dead(); // expected-warning {{will never be executed}} |
| 53 | goto b5; |
| 54 | a5: |
| 55 | live(), |
| 56 | halt(); |
| 57 | b5: |
| 58 | goto c5; |
| 59 | |
| 60 | case 6: |
| 61 | if (live()) |
| 62 | goto e6; |
| 63 | live(), |
| 64 | halt(); |
| 65 | d6: |
| 66 | dead(); // expected-warning {{will never be executed}} |
| 67 | goto b6; |
| 68 | c6: |
| 69 | dead(); |
| 70 | goto b6; |
| 71 | e6: |
| 72 | live(), |
| 73 | halt(); |
| 74 | b6: |
| 75 | goto c6; |
Mike Stump | 55f988e | 2010-01-21 17:21:23 +0000 | [diff] [blame] | 76 | case 7: |
| 77 | halt() |
| 78 | + // expected-warning {{will never be executed}} |
| 79 | dead(); |
| 80 | - // expected-warning {{will never be executed}} |
| 81 | halt(); |
Mike Stump | 45db90d | 2010-01-21 17:31:41 +0000 | [diff] [blame] | 82 | case 8: |
| 83 | i |
| 84 | += // expected-warning {{will never be executed}} |
| 85 | halt(); |
Mike Stump | e5fba70 | 2010-01-21 19:44:04 +0000 | [diff] [blame^] | 86 | case 9: |
| 87 | halt() |
| 88 | ? // expected-warning {{will never be executed}} |
| 89 | dead() : dead(); |
Mike Stump | 8eae090 | 2010-01-15 23:17:13 +0000 | [diff] [blame] | 90 | } |
| 91 | } |