xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/blocks-1.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5
2*f4a2713aSLionel Sambuc// RUN: grep "_Block_object_dispose" %t | count 6
3*f4a2713aSLionel Sambuc// RUN: grep "__copy_helper_block_" %t | count 4
4*f4a2713aSLionel Sambuc// RUN: grep "__destroy_helper_block_" %t | count 4
5*f4a2713aSLionel Sambuc// RUN: grep "__Block_byref_object_copy_" %t | count 2
6*f4a2713aSLionel Sambuc// RUN: grep "__Block_byref_object_dispose_" %t | count 2
7*f4a2713aSLionel Sambuc// RUN: not grep "i32 135)" %t
8*f4a2713aSLionel Sambuc// RUN: grep "_Block_object_assign" %t | count 4
9*f4a2713aSLionel Sambuc// RUN: grep "objc_read_weak" %t | count 2
10*f4a2713aSLionel Sambuc// RUN: grep "objc_assign_weak" %t | count 3
11*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5
12*f4a2713aSLionel Sambuc// RUN: grep "_Block_object_dispose" %t | count 6
13*f4a2713aSLionel Sambuc// RUN: grep "__copy_helper_block_" %t | count 4
14*f4a2713aSLionel Sambuc// RUN: grep "__destroy_helper_block_" %t | count 4
15*f4a2713aSLionel Sambuc// RUN: grep "__Block_byref_object_copy_" %t | count 2
16*f4a2713aSLionel Sambuc// RUN: grep "__Block_byref_object_dispose_" %t | count 2
17*f4a2713aSLionel Sambuc// RUN: not grep "i32 135)" %t
18*f4a2713aSLionel Sambuc// RUN: grep "_Block_object_assign" %t | count 4
19*f4a2713aSLionel Sambuc// RUN: grep "objc_read_weak" %t | count 2
20*f4a2713aSLionel Sambuc// RUN: grep "objc_assign_weak" %t | count 3
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc@interface NSDictionary @end
23*f4a2713aSLionel Sambuc
24*f4a2713aSLionel Sambucvoid test1(NSDictionary * dict) {
25*f4a2713aSLionel Sambuc  ^{ (void)dict; }();
26*f4a2713aSLionel Sambuc}
27*f4a2713aSLionel Sambuc
28*f4a2713aSLionel Sambuc@interface D
29*f4a2713aSLionel Sambuc@end
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambucvoid foo() {
32*f4a2713aSLionel Sambuc  __block __weak D *weakSelf;
33*f4a2713aSLionel Sambuc  D *l;
34*f4a2713aSLionel Sambuc  l = weakSelf;
35*f4a2713aSLionel Sambuc  weakSelf = l;
36*f4a2713aSLionel Sambuc}
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambucvoid (^__weak b)(void);
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambucvoid test2() {
41*f4a2713aSLionel Sambuc  __block int i = 0;
42*f4a2713aSLionel Sambuc  b = ^ {  ++i; };
43*f4a2713aSLionel Sambuc}
44