2 // The LLVM Compiler Infrastructure
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
7 // CONFIG open rdar://6416474
16 int main(int argc
, char* argv
[]) {
18 if (argc
> 1) verbose
= 1;
20 __block
void (^recursive_local_block
)(int);
22 if (verbose
) printf("recursive_local_block is a local recursive block\n");
23 recursive_local_block
= ^(int i
) {
24 if (verbose
) printf("%d\n", i
);
26 recursive_local_block(i
- 1);
30 if (verbose
) printf("recursive_local_block's address is %p, running it:\n", (void*)recursive_local_block
);
31 recursive_local_block(5);
33 if (verbose
) printf("Creating other_local_block: a local block that calls recursive_local_block\n");
35 void (^other_local_block
)(int) = ^(int i
) {
36 if (verbose
) printf("other_local_block running\n");
37 recursive_local_block(i
);
40 if (verbose
) printf("other_local_block's address is %p, running it:\n", (void*)other_local_block
);
44 #if __APPLE_CC__ >= 5627
45 if (verbose
) printf("Creating other_copied_block: a Block_copy of a block that will call recursive_local_block\n");
47 void (^other_copied_block
)(int) = Block_copy(^(int i
) {
48 if (verbose
) printf("other_copied_block running\n");
49 recursive_local_block(i
);
52 if (verbose
) printf("other_copied_block's address is %p, running it:\n", (void*)other_copied_block
);
54 other_copied_block(5);
57 __block
void (^recursive_copy_block
)(int);
59 if (verbose
) printf("Creating recursive_copy_block: a Block_copy of a block that will call recursive_copy_block recursively\n");
61 recursive_copy_block
= Block_copy(^(int i
) {
62 if (verbose
) printf("%d\n", i
);
64 recursive_copy_block(i
- 1);
68 if (verbose
) printf("recursive_copy_block's address is %p, running it:\n", (void*)recursive_copy_block
);
70 recursive_copy_block(5);
72 printf("%s: Success\n", argv
[0]);