xref: /llvm-project/compiler-rt/test/BlocksRuntime/copy-block-literal-rdar6439600.c (revision 2946cd701067404b99c39fb29dc9c74bd7193eb3)
18c1441f8SAlexey Samsonov //
2*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
4*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
58c1441f8SAlexey Samsonov 
68c1441f8SAlexey Samsonov // CONFIG open rdar://6439600
78c1441f8SAlexey Samsonov 
88c1441f8SAlexey Samsonov #import <stdio.h>
98c1441f8SAlexey Samsonov #import <stdlib.h>
108c1441f8SAlexey Samsonov 
118c1441f8SAlexey Samsonov #define NUMBER_OF_BLOCKS 100
main(int argc,const char * argv[])128c1441f8SAlexey Samsonov int main (int argc, const char * argv[]) {
138c1441f8SAlexey Samsonov     int (^x[NUMBER_OF_BLOCKS])();
148c1441f8SAlexey Samsonov     int i;
158c1441f8SAlexey Samsonov 
168c1441f8SAlexey Samsonov     for(i=0; i<NUMBER_OF_BLOCKS; i++) x[i] = ^{ return i; };
178c1441f8SAlexey Samsonov 
188c1441f8SAlexey Samsonov     for(i=0; i<NUMBER_OF_BLOCKS; i++) {
198c1441f8SAlexey Samsonov         if (x[i]() != i) {
208c1441f8SAlexey Samsonov             printf("%s: failure, %d != %d\n", argv[0], x[i](), i);
218c1441f8SAlexey Samsonov             exit(1);
228c1441f8SAlexey Samsonov         }
238c1441f8SAlexey Samsonov     }
248c1441f8SAlexey Samsonov 
258c1441f8SAlexey Samsonov     printf("%s: success\n", argv[0]);
268c1441f8SAlexey Samsonov 
278c1441f8SAlexey Samsonov     return 0;
288c1441f8SAlexey Samsonov }
29