1//
2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3// See https://llvm.org/LICENSE.txt for license information.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
6/*
7 * localisglobal.c
8 * testObjects
9 *
10 * Created by Blaine Garst on 9/29/08.
11 *
12 * works in all configurations
13 * CONFIG rdar://6230297
14 */
15
16#include <stdio.h>
17
18void (^global)(void) = ^{ printf("hello world\n"); };
19
20int aresame(void *first, void *second) {
21 long *f = (long *)first;
22 long *s = (long *)second;
23 return *f == *s;
24}
25int main(int argc, char *argv[]) {
26 int i = 10;
27 void (^local)(void) = ^ { printf("hi %d\n", i); };
28 void (^localisglobal)(void) = ^ { printf("hi\n"); };
29
30 if (aresame(local, localisglobal)) {
31 printf("local block could be global, but isn't\n");
32 return 1;
33 }
34 if (!aresame(global, localisglobal)) {
35 printf("local block is not global, not stack, what is it??\n");
36 return 1;
37 }
38 printf("%s: success\n", argv[0]);
39 return 0;
40
41}
42