Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc %s -emit-llvm-bc -o - | opt -std-compile-opts -disable-output |
Devang Patel | 51b09f2 | 2007-10-04 23:45:31 +0000 | [diff] [blame] | 2 | |
| 3 | int foo(int i) { |
| 4 | int j = 0; |
| 5 | switch (i) { |
Chris Lattner | c69a581 | 2007-11-30 17:44:57 +0000 | [diff] [blame] | 6 | case -1: |
| 7 | j = 1; break; |
Devang Patel | 51b09f2 | 2007-10-04 23:45:31 +0000 | [diff] [blame] | 8 | case 1 : |
| 9 | j = 2; break; |
| 10 | case 2: |
| 11 | j = 3; break; |
| 12 | default: |
| 13 | j = 42; break; |
| 14 | } |
| 15 | j = j + 1; |
| 16 | return j; |
| 17 | } |
| 18 | |
| 19 | |
Devang Patel | 2d79d0f | 2007-10-05 20:54:07 +0000 | [diff] [blame] | 20 | int foo2(int i) { |
| 21 | int j = 0; |
| 22 | switch (i) { |
| 23 | case 1 : |
| 24 | j = 2; break; |
| 25 | case 2 ... 10: |
| 26 | j = 3; break; |
| 27 | default: |
| 28 | j = 42; break; |
| 29 | } |
| 30 | j = j + 1; |
| 31 | return j; |
| 32 | } |
| 33 | |
| 34 | |
Devang Patel | c049e4f | 2007-10-08 20:57:48 +0000 | [diff] [blame] | 35 | int foo3(int i) { |
| 36 | int j = 0; |
| 37 | switch (i) { |
| 38 | default: |
| 39 | j = 42; break; |
| 40 | case 111: |
| 41 | j = 111; break; |
| 42 | case 0 ... 100: |
| 43 | j = 1; break; |
| 44 | case 222: |
| 45 | j = 222; break; |
| 46 | } |
| 47 | return j; |
| 48 | } |
| 49 | |
| 50 | |
| 51 | int foo4(int i) { |
| 52 | int j = 0; |
| 53 | switch (i) { |
| 54 | case 111: |
| 55 | j = 111; break; |
| 56 | case 0 ... 100: |
| 57 | j = 1; break; |
| 58 | case 222: |
| 59 | j = 222; break; |
| 60 | default: |
| 61 | j = 42; break; |
| 62 | case 501 ... 600: |
| 63 | j = 5; break; |
| 64 | } |
| 65 | return j; |
| 66 | } |
Chris Lattner | 1438b49 | 2007-12-01 05:27:33 +0000 | [diff] [blame] | 67 | |
| 68 | void foo5(){ |
| 69 | switch(0){ |
| 70 | default: |
| 71 | if (0) { |
| 72 | |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
Eli Friedman | d28a80d | 2008-05-12 16:08:04 +0000 | [diff] [blame] | 77 | void foo6(){ |
| 78 | switch(0){ |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void foo7(){ |
| 83 | switch(0){ |
| 84 | foo7(); |
| 85 | } |
| 86 | } |
| 87 | |