xref: /llvm-project/compiler-rt/test/BlocksRuntime/rdar6396238.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 rdar://6396238
78c1441f8SAlexey Samsonov 
88c1441f8SAlexey Samsonov #include <stdio.h>
98c1441f8SAlexey Samsonov #include <stdlib.h>
108c1441f8SAlexey Samsonov 
118c1441f8SAlexey Samsonov static int count = 0;
128c1441f8SAlexey Samsonov 
mkblock(void)138c1441f8SAlexey Samsonov void (^mkblock(void))(void)
148c1441f8SAlexey Samsonov {
158c1441f8SAlexey Samsonov     count++;
168c1441f8SAlexey Samsonov     return ^{
178c1441f8SAlexey Samsonov         count++;
188c1441f8SAlexey Samsonov     };
198c1441f8SAlexey Samsonov }
208c1441f8SAlexey Samsonov 
main(int argc,const char * argv[])218c1441f8SAlexey Samsonov int main (int argc, const char * argv[]) {
228c1441f8SAlexey Samsonov     mkblock()();
238c1441f8SAlexey Samsonov     if (count != 2) {
248c1441f8SAlexey Samsonov         printf("%s: failure, 2 != %d\n", argv[0], count);
258c1441f8SAlexey Samsonov         exit(1);
268c1441f8SAlexey Samsonov     } else {
278c1441f8SAlexey Samsonov         printf("%s: success\n", argv[0]);
288c1441f8SAlexey Samsonov         exit(0);
298c1441f8SAlexey Samsonov     }
308c1441f8SAlexey Samsonov     return 0;
318c1441f8SAlexey Samsonov }
32