John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp |
Fariborz Jahanian | 2f93a98 | 2010-01-24 18:40:06 +0000 | [diff] [blame] | 2 | // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s |
Fariborz Jahanian | 1d4fca2 | 2010-01-19 21:48:35 +0000 | [diff] [blame] | 3 | |
| 4 | extern "C" { |
| 5 | extern "C" void *_Block_copy(const void *aBlock); |
| 6 | extern "C" void _Block_release(const void *aBlock); |
| 7 | } |
| 8 | |
| 9 | int main() { |
| 10 | __attribute__((__blocks__(byref))) int a = 42; |
| 11 | int save_a = a; |
| 12 | |
| 13 | void (^b)(void) = ^{ |
| 14 | ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; }))); |
| 15 | }; |
| 16 | |
| 17 | ((__typeof(b))_Block_copy((const void *)(b))); |
| 18 | |
| 19 | return 0; |
| 20 | } |
| 21 | |
Fariborz Jahanian | 2f93a98 | 2010-01-24 18:40:06 +0000 | [diff] [blame] | 22 | // CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b))) |
| 23 | |
Fariborz Jahanian | 4c863ef | 2010-02-10 18:54:22 +0000 | [diff] [blame] | 24 | // radar 7628153 |
| 25 | void f() { |
| 26 | int a; |
| 27 | __typeof__(a) aVal = a; |
| 28 | char *a1t = (char *)@encode(__typeof__(a)); |
| 29 | __typeof__(aVal) bVal; |
| 30 | char *a2t = (char *)@encode(__typeof__(bVal)); |
| 31 | __typeof__(bVal) cVal = bVal; |
| 32 | char *a3t = (char *)@encode(__typeof__(cVal)); |
| 33 | |
| 34 | } |
| 35 | |
| 36 | |
| 37 | // CHECK-LP: int aVal = a; |
| 38 | |
| 39 | // CHECK-LP: int bVal; |