summaryrefslogtreecommitdiffstats
path: root/test/Rewriter/rewrite-block-literal.mm
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-03-23 00:00:49 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-03-23 00:00:49 +0000
commitdf474ec64a86bb88c7543875634d3fc628105bb5 (patch)
treecfcaae7f0d20cdde7b22258172fc779660312e43 /test/Rewriter/rewrite-block-literal.mm
parent263e0a6106f58a43ae67b28e92d8af6716e61c69 (diff)
modern objc translation of block literal expressions
declared at file scope. // rdar://11006566 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153293 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Rewriter/rewrite-block-literal.mm')
-rw-r--r--test/Rewriter/rewrite-block-literal.mm74
1 files changed, 74 insertions, 0 deletions
diff --git a/test/Rewriter/rewrite-block-literal.mm b/test/Rewriter/rewrite-block-literal.mm
new file mode 100644
index 0000000000..732d0b9f8d
--- /dev/null
+++ b/test/Rewriter/rewrite-block-literal.mm
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+// rdar: // 11006566
+
+void I( void (^)(void));
+void (^noop)(void);
+
+void nothing();
+int printf(const char*, ...);
+
+typedef void (^T) (void);
+
+void takeblock(T);
+int takeintint(int (^C)(int)) { return C(4); }
+
+T somefunction() {
+ if (^{ })
+ nothing();
+
+ noop = ^{};
+
+ noop = ^{printf("\nClosure\n"); };
+
+ I(^{ });
+
+ return ^{printf("\nClosure\n"); };
+}
+void test2() {
+ int x = 4;
+
+ takeblock(^{ printf("%d\n", x); });
+
+ while (1) {
+ takeblock(^{
+ while(1) break; // ok
+ });
+ break;
+ }
+}
+
+void test4() {
+ void (^noop)(void) = ^{};
+ void (*noop2)() = 0;
+}
+
+void myfunc(int (^block)(int)) {}
+
+void myfunc3(const int *x);
+
+void test5() {
+ int a;
+
+ myfunc(^(int abcd) {
+ myfunc3(&a);
+ return 1;
+ });
+}
+
+void *X;
+
+static int global_x = 10;
+void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
+
+// CHECK: static __global_block_block_impl_0 __global_global_block_block_impl_0((void *)__global_block_block_func_0, &__global_block_block_desc_0_DATA);
+// CHECK: void (*global_block)(void) = (void (*)())&__global_global_block_block_impl_0;
+
+typedef void (^void_block_t)(void);
+
+static const void_block_t myBlock = ^{ };
+
+static const void_block_t myBlock2 = ^ void(void) { };