xref: /aosp_15_r20/external/compiler-rt/test/BlocksRuntime/recursiveassign.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 /*
8*7c3d14c8STreehugger Robot  *  recursiveassign.c
9*7c3d14c8STreehugger Robot  *  testObjects
10*7c3d14c8STreehugger Robot  *
11*7c3d14c8STreehugger Robot  *  Created by Blaine Garst on 12/3/08.
12*7c3d14c8STreehugger Robot  *
13*7c3d14c8STreehugger Robot  */
14*7c3d14c8STreehugger Robot 
15*7c3d14c8STreehugger Robot // CONFIG  rdar://6639533
16*7c3d14c8STreehugger Robot 
17*7c3d14c8STreehugger Robot // The compiler is prefetching x->forwarding before evaluting code that recomputes forwarding and so the value goes to a place that is never seen again.
18*7c3d14c8STreehugger Robot 
19*7c3d14c8STreehugger Robot #include <stdio.h>
20*7c3d14c8STreehugger Robot #include <stdlib.h>
21*7c3d14c8STreehugger Robot #include <Block.h>
22*7c3d14c8STreehugger Robot 
23*7c3d14c8STreehugger Robot 
main(int argc,char * argv[])24*7c3d14c8STreehugger Robot int main(int argc, char* argv[]) {
25*7c3d14c8STreehugger Robot 
26*7c3d14c8STreehugger Robot     __block void (^recursive_copy_block)(int) = ^(int arg) { printf("got wrong Block\n"); exit(1); };
27*7c3d14c8STreehugger Robot 
28*7c3d14c8STreehugger Robot 
29*7c3d14c8STreehugger Robot     recursive_copy_block = Block_copy(^(int i) {
30*7c3d14c8STreehugger Robot         if (i > 0) {
31*7c3d14c8STreehugger Robot             recursive_copy_block(i - 1);
32*7c3d14c8STreehugger Robot         }
33*7c3d14c8STreehugger Robot         else {
34*7c3d14c8STreehugger Robot             printf("done!\n");
35*7c3d14c8STreehugger Robot         }
36*7c3d14c8STreehugger Robot     });
37*7c3d14c8STreehugger Robot 
38*7c3d14c8STreehugger Robot 
39*7c3d14c8STreehugger Robot     recursive_copy_block(5);
40*7c3d14c8STreehugger Robot 
41*7c3d14c8STreehugger Robot     printf("%s: Success\n", argv[0]);
42*7c3d14c8STreehugger Robot     return 0;
43*7c3d14c8STreehugger Robot }
44*7c3d14c8STreehugger Robot 
45