summaryrefslogtreecommitdiffstats
path: root/test/CodeGen/switch.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen/switch.c')
-rw-r--r--test/CodeGen/switch.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/test/CodeGen/switch.c b/test/CodeGen/switch.c
new file mode 100644
index 0000000..3254fbf
--- /dev/null
+++ b/test/CodeGen/switch.c
@@ -0,0 +1,87 @@
+// RUN: clang-cc %s -emit-llvm-bc -o - | opt -std-compile-opts -disable-output
+
+int foo(int i) {
+ int j = 0;
+ switch (i) {
+ case -1:
+ j = 1; break;
+ case 1 :
+ j = 2; break;
+ case 2:
+ j = 3; break;
+ default:
+ j = 42; break;
+ }
+ j = j + 1;
+ return j;
+}
+
+
+int foo2(int i) {
+ int j = 0;
+ switch (i) {
+ case 1 :
+ j = 2; break;
+ case 2 ... 10:
+ j = 3; break;
+ default:
+ j = 42; break;
+ }
+ j = j + 1;
+ return j;
+}
+
+
+int foo3(int i) {
+ int j = 0;
+ switch (i) {
+ default:
+ j = 42; break;
+ case 111:
+ j = 111; break;
+ case 0 ... 100:
+ j = 1; break;
+ case 222:
+ j = 222; break;
+ }
+ return j;
+}
+
+
+int foo4(int i) {
+ int j = 0;
+ switch (i) {
+ case 111:
+ j = 111; break;
+ case 0 ... 100:
+ j = 1; break;
+ case 222:
+ j = 222; break;
+ default:
+ j = 42; break;
+ case 501 ... 600:
+ j = 5; break;
+ }
+ return j;
+}
+
+void foo5(){
+ switch(0){
+ default:
+ if (0) {
+
+ }
+ }
+}
+
+void foo6(){
+ switch(0){
+ }
+}
+
+void foo7(){
+ switch(0){
+ foo7();
+ }
+}
+
OpenPOWER on IntegriCloud