Blaine Garst | 86d0ba4 | 2010-08-04 23:34:21 +0000 | [diff] [blame] | 1 | // |
| 2 | // The LLVM Compiler Infrastructure |
| 3 | // |
| 4 | // This file is distributed under the University of Illinois Open Source |
| 5 | // License. See LICENSE.TXT for details. |
| 6 | |
| 7 | /* |
| 8 | * localisglobal.c |
| 9 | * testObjects |
| 10 | * |
| 11 | * Created by Blaine Garst on 9/29/08. |
| 12 | * |
| 13 | * works in all configurations |
| 14 | * CONFIG rdar://6230297 |
| 15 | */ |
| 16 | |
| 17 | #include <stdio.h> |
| 18 | |
| 19 | void (^global)(void) = ^{ printf("hello world\n"); }; |
| 20 | |
| 21 | int aresame(void *first, void *second) { |
| 22 | long *f = (long *)first; |
| 23 | long *s = (long *)second; |
| 24 | return *f == *s; |
| 25 | } |
| 26 | int main(int argc, char *argv[]) { |
| 27 | int i = 10; |
| 28 | void (^local)(void) = ^ { printf("hi %d\n", i); }; |
| 29 | void (^localisglobal)(void) = ^ { printf("hi\n"); }; |
| 30 | |
| 31 | if (aresame(local, localisglobal)) { |
| 32 | printf("local block could be global, but isn't\n"); |
| 33 | return 1; |
| 34 | } |
| 35 | if (!aresame(global, localisglobal)) { |
| 36 | printf("local block is not global, not stack, what is it??\n"); |
| 37 | return 1; |
| 38 | } |
| 39 | printf("%s: success\n", argv[0]); |
| 40 | return 0; |
| 41 | |
| 42 | } |