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 * localisglobal.c
9*7c3d14c8STreehugger Robot * testObjects
10*7c3d14c8STreehugger Robot *
11*7c3d14c8STreehugger Robot * Created by Blaine Garst on 9/29/08.
12*7c3d14c8STreehugger Robot *
13*7c3d14c8STreehugger Robot * works in all configurations
14*7c3d14c8STreehugger Robot * CONFIG rdar://6230297
15*7c3d14c8STreehugger Robot */
16*7c3d14c8STreehugger Robot
17*7c3d14c8STreehugger Robot #include <stdio.h>
18*7c3d14c8STreehugger Robot
19*7c3d14c8STreehugger Robot void (^global)(void) = ^{ printf("hello world\n"); };
20*7c3d14c8STreehugger Robot
aresame(void * first,void * second)21*7c3d14c8STreehugger Robot int aresame(void *first, void *second) {
22*7c3d14c8STreehugger Robot long *f = (long *)first;
23*7c3d14c8STreehugger Robot long *s = (long *)second;
24*7c3d14c8STreehugger Robot return *f == *s;
25*7c3d14c8STreehugger Robot }
main(int argc,char * argv[])26*7c3d14c8STreehugger Robot int main(int argc, char *argv[]) {
27*7c3d14c8STreehugger Robot int i = 10;
28*7c3d14c8STreehugger Robot void (^local)(void) = ^ { printf("hi %d\n", i); };
29*7c3d14c8STreehugger Robot void (^localisglobal)(void) = ^ { printf("hi\n"); };
30*7c3d14c8STreehugger Robot
31*7c3d14c8STreehugger Robot if (aresame(local, localisglobal)) {
32*7c3d14c8STreehugger Robot printf("local block could be global, but isn't\n");
33*7c3d14c8STreehugger Robot return 1;
34*7c3d14c8STreehugger Robot }
35*7c3d14c8STreehugger Robot if (!aresame(global, localisglobal)) {
36*7c3d14c8STreehugger Robot printf("local block is not global, not stack, what is it??\n");
37*7c3d14c8STreehugger Robot return 1;
38*7c3d14c8STreehugger Robot }
39*7c3d14c8STreehugger Robot printf("%s: success\n", argv[0]);
40*7c3d14c8STreehugger Robot return 0;
41*7c3d14c8STreehugger Robot
42*7c3d14c8STreehugger Robot }
43