summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/switch.c
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-01-12 03:41:02 +0000
committerJohn McCall <rjmccall@apple.com>2011-01-12 03:41:02 +0000
commit20f6ab828a18d21091060966b42bbb4b2908a312 (patch)
treebfafeec67298e4f260e34cdd81b78695cebea06a /clang/test/CodeGen/switch.c
parentdd5f60b7a7c99f33d63fc2ce660850ba1c0f22b8 (diff)
downloadbcm5719-llvm-20f6ab828a18d21091060966b42bbb4b2908a312.tar.gz
bcm5719-llvm-20f6ab828a18d21091060966b42bbb4b2908a312.zip
Fix a latent bug where, after emitting an expression statement, we would
delete the block we began emitting into if it had no predecessors. We never want to do this, because there are several valid cases during statement emission where an existing block has no known predecessors but will acquire some later. The case in my test case doesn't inherently fall into this category, because we could safely emit the case-range code before the statement body, but there are examples with labels that can't be fallen into that would also demonstrate this bug. rdar://problem/8837067 llvm-svn: 123303
Diffstat (limited to 'clang/test/CodeGen/switch.c')
-rw-r--r--clang/test/CodeGen/switch.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/CodeGen/switch.c b/clang/test/CodeGen/switch.c
index dc2d27bc16d..8b94a0976e6 100644
--- a/clang/test/CodeGen/switch.c
+++ b/clang/test/CodeGen/switch.c
@@ -194,3 +194,20 @@ int f13(unsigned x) {
return 0;
}
}
+
+// Don't delete a basic block that we want to introduce later references to.
+// This isn't really specific to switches, but it's easy to show with them.
+// rdar://problem/8837067
+int f14(int x) {
+ switch (x) {
+
+ // case range so that the case block has no predecessors
+ case 0 ... 15:
+ // any expression which doesn't introduce a new block
+ (void) 0;
+ // kaboom
+
+ default:
+ return x;
+ }
+}
OpenPOWER on IntegriCloud