Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -rewrite-blocks %s -fblocks -o - |
Steve Naroff | eab5f63 | 2008-09-23 19:24:41 +0000 | [diff] [blame] | 2 | |
Steve Naroff | ca74360 | 2008-10-15 18:38:58 +0000 | [diff] [blame] | 3 | static int (^block)(const void *, const void *) = (int (^)(const void *, const void *))0; |
| 4 | static int (*func)(int (^block)(void *, void *)) = (int (*)(int (^block)(void *, void *)))0; |
| 5 | |
| 6 | typedef int (^block_T)(const void *, const void *); |
| 7 | typedef int (*func_T)(int (^block)(void *, void *)); |
| 8 | |
| 9 | void foo(const void *a, const void *b, void *c) { |
| 10 | int (^block)(const void *, const void *) = (int (^)(const void *, const void *))c; |
| 11 | int (*func)(int (^block)(void *, void *)) = (int (*)(int (^block)(void *, void *)))c; |
| 12 | } |
| 13 | |
Steve Naroff | eab5f63 | 2008-09-23 19:24:41 +0000 | [diff] [blame] | 14 | typedef void (^test_block_t)(); |
| 15 | |
| 16 | int main(int argc, char **argv) { |
| 17 | int a; |
| 18 | |
| 19 | void (^test_block_v)(); |
| 20 | void (^test_block_v2)(int, float); |
| 21 | |
| 22 | void (^test_block_v3)(void (^barg)(int)); |
| 23 | |
| 24 | a = 77; |
| 25 | test_block_v = ^(){ int local=1; printf("a=%d\n",a+local); }; |
| 26 | test_block_v(); |
| 27 | a++; |
| 28 | test_block_v(); |
| 29 | |
| 30 | __block int b; |
| 31 | |
| 32 | b = 88; |
| 33 | test_block_v2 = ^(int x, float f){ printf("b=%d\n",b); }; |
| 34 | test_block_v2(1,2.0); |
| 35 | b++; |
| 36 | test_block_v2(3,4.0); |
| 37 | return 7; |
| 38 | } |