summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/blocks.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-11-11 03:19:12 +0000
committerJohn McCall <rjmccall@apple.com>2011-11-11 03:19:12 +0000
commitf1a3c2aee1de6af989d52acf631b50713597e69d (patch)
tree98adb3b1261d0fbb87260787c5b4789d04e2aa6f /clang/test/CodeGenCXX/blocks.cpp
parentc4a001478c813b8f6f14d781f325da2ef4f689fd (diff)
downloadbcm5719-llvm-f1a3c2aee1de6af989d52acf631b50713597e69d.tar.gz
bcm5719-llvm-f1a3c2aee1de6af989d52acf631b50713597e69d.zip
Be sure to insulate block literals from any cleanups in their
enclosing full-expressions. It is somewhat amazing that this hasn't come up as a problem before. llvm-svn: 144362
Diffstat (limited to 'clang/test/CodeGenCXX/blocks.cpp')
-rw-r--r--clang/test/CodeGenCXX/blocks.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/blocks.cpp b/clang/test/CodeGenCXX/blocks.cpp
index 40faf1bf235..921d94a138a 100644
--- a/clang/test/CodeGenCXX/blocks.cpp
+++ b/clang/test/CodeGenCXX/blocks.cpp
@@ -178,3 +178,28 @@ namespace test5 {
// CHECK: call void @_ZN5test51AD1Ev([[A]]* [[X]])
// CHECK-NEXT: ret void
}
+
+namespace test6 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ void foo(const A &, void (^)());
+ void bar();
+
+ void test() {
+ // Make sure that the temporary cleanup isn't somehow captured
+ // within the block.
+ foo(A(), ^{ bar(); });
+ bar();
+ }
+
+ // CHECK: define void @_ZN5test64testEv()
+ // CHECK: [[TEMP:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK-NEXT: call void @_ZN5test61AC1Ev([[A]]* [[TEMP]])
+ // CHECK-NEXT: call void @_ZN5test63fooERKNS_1AEU13block_pointerFvvE(
+ // CHECK-NEXT: call void @_ZN5test61AD1Ev([[A]]* [[TEMP]])
+ // CHECK-NEXT: call void @_ZN5test63barEv()
+ // CHECK-NEXT: ret void
+}
OpenPOWER on IntegriCloud