xref: /llvm-project/compiler-rt/test/BlocksRuntime/copy-block-literal-rdar6439600.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 open rdar://6439600
7 
8 #import <stdio.h>
9 #import <stdlib.h>
10 
11 #define NUMBER_OF_BLOCKS 100
main(int argc,const char * argv[])12 int main (int argc, const char * argv[]) {
13     int (^x[NUMBER_OF_BLOCKS])();
14     int i;
15 
16     for(i=0; i<NUMBER_OF_BLOCKS; i++) x[i] = ^{ return i; };
17 
18     for(i=0; i<NUMBER_OF_BLOCKS; i++) {
19         if (x[i]() != i) {
20             printf("%s: failure, %d != %d\n", argv[0], x[i](), i);
21             exit(1);
22         }
23     }
24 
25     printf("%s: success\n", argv[0]);
26 
27     return 0;
28 }
29