xref: /aosp_15_r20/external/compiler-rt/test/BlocksRuntime/rdar6396238.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot //
2*7c3d14c8STreehugger Robot //                     The LLVM Compiler Infrastructure
3*7c3d14c8STreehugger Robot //
4*7c3d14c8STreehugger Robot // This file is distributed under the University of Illinois Open Source
5*7c3d14c8STreehugger Robot // License. See LICENSE.TXT for details.
6*7c3d14c8STreehugger Robot 
7*7c3d14c8STreehugger Robot // CONFIG rdar://6396238
8*7c3d14c8STreehugger Robot 
9*7c3d14c8STreehugger Robot #include <stdio.h>
10*7c3d14c8STreehugger Robot #include <stdlib.h>
11*7c3d14c8STreehugger Robot 
12*7c3d14c8STreehugger Robot static int count = 0;
13*7c3d14c8STreehugger Robot 
mkblock(void)14*7c3d14c8STreehugger Robot void (^mkblock(void))(void)
15*7c3d14c8STreehugger Robot {
16*7c3d14c8STreehugger Robot     count++;
17*7c3d14c8STreehugger Robot     return ^{
18*7c3d14c8STreehugger Robot         count++;
19*7c3d14c8STreehugger Robot     };
20*7c3d14c8STreehugger Robot }
21*7c3d14c8STreehugger Robot 
main(int argc,const char * argv[])22*7c3d14c8STreehugger Robot int main (int argc, const char * argv[]) {
23*7c3d14c8STreehugger Robot     mkblock()();
24*7c3d14c8STreehugger Robot     if (count != 2) {
25*7c3d14c8STreehugger Robot         printf("%s: failure, 2 != %d\n", argv[0], count);
26*7c3d14c8STreehugger Robot         exit(1);
27*7c3d14c8STreehugger Robot     } else {
28*7c3d14c8STreehugger Robot         printf("%s: success\n", argv[0]);
29*7c3d14c8STreehugger Robot         exit(0);
30*7c3d14c8STreehugger Robot     }
31*7c3d14c8STreehugger Robot     return 0;
32*7c3d14c8STreehugger Robot }
33