Fariborz Jahanian | 653b7cf | 2012-04-13 18:00:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp |
| 2 | // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp |
| 4 | |
Fariborz Jahanian | 8b08adb | 2012-05-03 21:44:12 +0000 | [diff] [blame] | 5 | typedef unsigned long size_t; |
Fariborz Jahanian | 653b7cf | 2012-04-13 18:00:54 +0000 | [diff] [blame] | 6 | extern "C" { |
| 7 | extern "C" void *_Block_copy(const void *aBlock); |
| 8 | extern "C" void _Block_release(const void *aBlock); |
| 9 | } |
| 10 | |
| 11 | int main() { |
| 12 | __attribute__((__blocks__(byref))) int a = 42; |
| 13 | int save_a = a; |
| 14 | |
| 15 | void (^b)(void) = ^{ |
| 16 | ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; }))); |
| 17 | }; |
| 18 | |
| 19 | ((__typeof(b))_Block_copy((const void *)(b))); |
| 20 | |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | // CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b))) |
| 25 | |
| 26 | // radar 7628153 |
| 27 | void f() { |
| 28 | int a; |
| 29 | __typeof__(a) aVal = a; |
| 30 | char *a1t = (char *)@encode(__typeof__(a)); |
| 31 | __typeof__(aVal) bVal; |
| 32 | char *a2t = (char *)@encode(__typeof__(bVal)); |
| 33 | __typeof__(bVal) cVal = bVal; |
| 34 | char *a3t = (char *)@encode(__typeof__(cVal)); |
| 35 | |
| 36 | } |
| 37 | |
| 38 | // rdar://11239324 |
| 39 | void x() { |
| 40 | id y; |
| 41 | void (^z)() = ^{ }; |
| 42 | y = (id)((__typeof(z))_Block_copy((const void *)(z))); |
| 43 | } |
| 44 | |
| 45 | // CHECK-LP: int aVal = a; |
| 46 | |
| 47 | // CHECK-LP: int bVal; |