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 /*
78c1441f8SAlexey Samsonov * localisglobal.c
88c1441f8SAlexey Samsonov * testObjects
98c1441f8SAlexey Samsonov *
108c1441f8SAlexey Samsonov * Created by Blaine Garst on 9/29/08.
118c1441f8SAlexey Samsonov *
128c1441f8SAlexey Samsonov * works in all configurations
138c1441f8SAlexey Samsonov * CONFIG rdar://6230297
148c1441f8SAlexey Samsonov */
158c1441f8SAlexey Samsonov
168c1441f8SAlexey Samsonov #include <stdio.h>
178c1441f8SAlexey Samsonov
188c1441f8SAlexey Samsonov void (^global)(void) = ^{ printf("hello world\n"); };
198c1441f8SAlexey Samsonov
aresame(void * first,void * second)208c1441f8SAlexey Samsonov int aresame(void *first, void *second) {
218c1441f8SAlexey Samsonov long *f = (long *)first;
228c1441f8SAlexey Samsonov long *s = (long *)second;
238c1441f8SAlexey Samsonov return *f == *s;
248c1441f8SAlexey Samsonov }
main(int argc,char * argv[])258c1441f8SAlexey Samsonov int main(int argc, char *argv[]) {
268c1441f8SAlexey Samsonov int i = 10;
278c1441f8SAlexey Samsonov void (^local)(void) = ^ { printf("hi %d\n", i); };
288c1441f8SAlexey Samsonov void (^localisglobal)(void) = ^ { printf("hi\n"); };
298c1441f8SAlexey Samsonov
308c1441f8SAlexey Samsonov if (aresame(local, localisglobal)) {
318c1441f8SAlexey Samsonov printf("local block could be global, but isn't\n");
328c1441f8SAlexey Samsonov return 1;
338c1441f8SAlexey Samsonov }
348c1441f8SAlexey Samsonov if (!aresame(global, localisglobal)) {
358c1441f8SAlexey Samsonov printf("local block is not global, not stack, what is it??\n");
368c1441f8SAlexey Samsonov return 1;
378c1441f8SAlexey Samsonov }
388c1441f8SAlexey Samsonov printf("%s: success\n", argv[0]);
398c1441f8SAlexey Samsonov return 0;
408c1441f8SAlexey Samsonov
418c1441f8SAlexey Samsonov }
42