| 1 |
// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp |
| 2 |
// RUN: FileCheck -check-prefix CHECK-LP --input-file=%t-rw.cpp %s |
| 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 |
|
| 22 |
// CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b))) |
| 23 |
|
| 24 |
void f() { |
| 25 |
int a; |
| 26 |
__typeof__(a) aVal = a; |
| 27 |
char *a1t = (char *)@encode(__typeof__(a)); |
| 28 |
__typeof__(aVal) bVal; |
| 29 |
char *a2t = (char *)@encode(__typeof__(bVal)); |
| 30 |
__typeof__(bVal) cVal = bVal; |
| 31 |
char *a3t = (char *)@encode(__typeof__(cVal)); |
| 32 |
|
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
// CHECK-LP: int aVal = a; |
| 37 |
|
| 38 |
// CHECK-LP: int bVal; |