blob: 3254fbf3c9389dfcbb3e79434753df26185b1a6f [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc %s -emit-llvm-bc -o - | opt -std-compile-opts -disable-output
Devang Patel51b09f22007-10-04 23:45:31 +00002
3int foo(int i) {
4 int j = 0;
5 switch (i) {
Chris Lattnerc69a5812007-11-30 17:44:57 +00006 case -1:
7 j = 1; break;
Devang Patel51b09f22007-10-04 23:45:31 +00008 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 Patel2d79d0f2007-10-05 20:54:07 +000020int 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 Patelc049e4f2007-10-08 20:57:48 +000035int 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
51int 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 Lattner1438b492007-12-01 05:27:33 +000067
68void foo5(){
69 switch(0){
70 default:
71 if (0) {
72
73 }
74 }
75}
76
Eli Friedmand28a80d2008-05-12 16:08:04 +000077void foo6(){
78 switch(0){
79 }
80}
81
82void foo7(){
83 switch(0){
84 foo7();
85 }
86}
87