xref: /llvm-project/compiler-rt/test/BlocksRuntime/rdar6405500.c (revision 2946cd701067404b99c39fb29dc9c74bd7193eb3)
1 //
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 
6 // CONFIG rdar://6405500
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #import <dispatch/dispatch.h>
11 #import <objc/objc-auto.h>
12 
main(int argc,const char * argv[])13 int main (int argc, const char * argv[]) {
14     __block void (^blockFu)(size_t t);
15     blockFu = ^(size_t t){
16         if (t == 20) {
17             printf("%s: success\n", argv[0]);
18             exit(0);
19         } else
20             dispatch_async(dispatch_get_main_queue(), ^{ blockFu(20); });
21     };
22 
23     dispatch_apply(10, dispatch_get_concurrent_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT), blockFu);
24 
25     dispatch_main();
26     printf("shouldn't get here\n");
27     return 1;
28 }
29