Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / BlocksRuntime / localisglobal.c
blobc4e5628b53218fedf40a62a43e5a68af8226a6ea
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
6 /*
7 * localisglobal.c
8 * testObjects
10 * Created by Blaine Garst on 9/29/08.
12 * works in all configurations
13 * CONFIG rdar://6230297
16 #include <stdio.h>
18 void (^global)(void) = ^{ printf("hello world\n"); };
20 int aresame(void *first, void *second) {
21 long *f = (long *)first;
22 long *s = (long *)second;
23 return *f == *s;
25 int 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"); };
30 if (aresame(local, localisglobal)) {
31 printf("local block could be global, but isn't\n");
32 return 1;
34 if (!aresame(global, localisglobal)) {
35 printf("local block is not global, not stack, what is it??\n");
36 return 1;
38 printf("%s: success\n", argv[0]);
39 return 0;