In the latest episode of "Deserializing bugs caused by accessors" the series reached...
[clang.git] / test / Rewriter / rewrite-block-literal.c
blobbe9c06f7db2595da11b5a379a1487ff15c9d6d42
1 // RUN: %clang_cc1 -rewrite-objc %s -fblocks -o -
3 void I( void (^)(void));
4 void (^noop)(void);
6 void nothing();
7 int printf(const char*, ...);
9 typedef void (^T) (void);
11 void takeblock(T);
12 int takeintint(int (^C)(int)) { return C(4); }
14 T somefunction() {
15 if (^{ })
16 nothing();
18 noop = ^{};
20 noop = ^{printf("\nClosure\n"); };
22 I(^{ });
24 return ^{printf("\nClosure\n"); };
26 void test2() {
27 int x = 4;
29 takeblock(^{ printf("%d\n", x); });
31 while (1) {
32 takeblock(^{
33 while(1) break; // ok
34 });
35 break;
40 void (^test3())(void) {
41 return ^{};
44 void test4() {
45 void (^noop)(void) = ^{};
46 void (*noop2)() = 0;
49 void myfunc(int (^block)(int)) {}
51 void myfunc3(const int *x);
53 void test5() {
54 int a;
56 myfunc(^(int abcd) {
57 myfunc3(&a);
58 return 1;
59 });
62 void *X;
64 void test_arguments() {
65 int y;
66 int (^c)(char);
67 (1 ? c : 0)('x');
68 (1 ? 0 : c)('x');
70 (1 ? c : c)('x');
73 static int global_x = 10;
74 void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
76 typedef void (^void_block_t)(void);
78 static const void_block_t myBlock = ^{ };
80 static const void_block_t myBlock2 = ^ void(void) { };