blob: 92ef7e9336150e6f75fa738b67a3b6b5f7ae2599 [file] [log] [blame]
John McCall260611a2012-06-20 06:18:46 +00001// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp
Tim Northover931a4fe2013-08-12 12:51:05 +00002// RUN: FileCheck -check-prefix CHECK-LP --input-file=%t-rw.cpp %s
Fariborz Jahanian9d9e3dd2011-07-31 20:27:31 +00003// rdar://9846759
4
5typedef void (^dispatch_block_t)(void);
6
7extern int printf(const char*, ...);
8
9extern "C" dispatch_block_t Block_copy(dispatch_block_t aBlock);
10
11int main (int argc, char *argv[]) {
12
13 dispatch_block_t innerBlock = ^{printf("argc = %d\n", argc); };
14 id innerObject = 0;
15
16 printf("innerBlock is %x\n", innerBlock);
17
18 dispatch_block_t wrapperBlock = ^{
19 printf("innerBlock is %x %x\n", innerBlock, innerObject);
20 };
21
22 wrapperBlock();
23
24 dispatch_block_t copiedBlock = Block_copy(wrapperBlock);
25 copiedBlock();
26
27 return 0;
28}
29// CHECK-LP: _Block_object_assign((void*)&dst->innerBlock, (void*)src->innerBlock, 7
30// CHECK-LP: _Block_object_dispose((void*)src->innerBlock, 7
31// CHECK-LP: _Block_object_assign((void*)&dst->innerObject, (void*)src->innerObject, 3
32// CHECK-LP: _Block_object_dispose((void*)src->innerObject, 3