blob: be9c06f7db2595da11b5a379a1487ff15c9d6d42 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -rewrite-objc %s -fblocks -o -
Fariborz Jahanian8a9e1702009-12-15 17:30:20 +00002
3void I( void (^)(void));
4void (^noop)(void);
5
6void nothing();
7int printf(const char*, ...);
8
9typedef void (^T) (void);
10
11void takeblock(T);
12int takeintint(int (^C)(int)) { return C(4); }
13
14T somefunction() {
15 if (^{ })
16 nothing();
17
18 noop = ^{};
19
20 noop = ^{printf("\nClosure\n"); };
21
22 I(^{ });
23
24 return ^{printf("\nClosure\n"); };
25}
26void test2() {
27 int x = 4;
28
29 takeblock(^{ printf("%d\n", x); });
30
31 while (1) {
32 takeblock(^{
33 while(1) break; // ok
34 });
35 break;
36 }
37}
38
39
40void (^test3())(void) {
41 return ^{};
42}
43
44void test4() {
45 void (^noop)(void) = ^{};
46 void (*noop2)() = 0;
47}
48
49void myfunc(int (^block)(int)) {}
50
51void myfunc3(const int *x);
52
53void test5() {
54 int a;
55
56 myfunc(^(int abcd) {
57 myfunc3(&a);
58 return 1;
59 });
60}
61
62void *X;
63
64void test_arguments() {
65 int y;
66 int (^c)(char);
67 (1 ? c : 0)('x');
68 (1 ? 0 : c)('x');
69
70 (1 ? c : c)('x');
71}
72
73static int global_x = 10;
74void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
75
76typedef void (^void_block_t)(void);
77
78static const void_block_t myBlock = ^{ };
79
80static const void_block_t myBlock2 = ^ void(void) { };