| 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 | |
| 18 | void (^global)(void) = ^{ printf(format: "hello world\n" ); }; |
| 19 | |
| 20 | int aresame(void *first, void *second) { |
| 21 | long *f = (long *)first; |
| 22 | long *s = (long *)second; |
| 23 | return *f == *s; |
| 24 | } |
| 25 | int main(int argc, char *argv[]) { |
| 26 | int i = 10; |
| 27 | void (^local)(void) = ^ { printf(format: "hi %d\n" , i); }; |
| 28 | void (^localisglobal)(void) = ^ { printf(format: "hi\n" ); }; |
| 29 | |
| 30 | if (aresame(first: local, second: localisglobal)) { |
| 31 | printf(format: "local block could be global, but isn't\n" ); |
| 32 | return 1; |
| 33 | } |
| 34 | if (!aresame(first: global, second: localisglobal)) { |
| 35 | printf(format: "local block is not global, not stack, what is it??\n" ); |
| 36 | return 1; |
| 37 | } |
| 38 | printf(format: "%s: success\n" , argv[0]); |
| 39 | return 0; |
| 40 | |
| 41 | } |
| 42 | |