xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/arc-captured-block-var-layout.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout
2*f4a2713aSLionel Sambuc// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.layout %s
3*f4a2713aSLionel Sambuc// rdar://12184410
4*f4a2713aSLionel Sambuc// rdar://12752901
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambucvoid x(id y) {}
7*f4a2713aSLionel Sambucvoid y(int a) {}
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambucextern id opaque_id();
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambucvoid f() {
12*f4a2713aSLionel Sambuc    __weak id wid;
13*f4a2713aSLionel Sambuc    __block int byref_int = 0;
14*f4a2713aSLionel Sambuc    char ch = 'a';
15*f4a2713aSLionel Sambuc    char ch1 = 'b';
16*f4a2713aSLionel Sambuc    char ch2 = 'c';
17*f4a2713aSLionel Sambuc    short sh = 2;
18*f4a2713aSLionel Sambuc    const id bar = (id) opaque_id();
19*f4a2713aSLionel Sambuc    id baz = 0;
20*f4a2713aSLionel Sambuc    __strong id strong_void_sta;
21*f4a2713aSLionel Sambuc    __block id byref_bab = (id)0;
22*f4a2713aSLionel Sambuc    __block id bl_var1;
23*f4a2713aSLionel Sambuc    int i; double dob;
24*f4a2713aSLionel Sambuc
25*f4a2713aSLionel Sambuc// The patterns here are a sequence of bytes, each saying first how
26*f4a2713aSLionel Sambuc// many sizeof(void*) chunks to skip (high nibble) and then how many
27*f4a2713aSLionel Sambuc// to scan (low nibble).  A zero byte says that we've reached the end
28*f4a2713aSLionel Sambuc// of the pattern.
29*f4a2713aSLionel Sambuc//
30*f4a2713aSLionel Sambuc// All of these patterns start with 01 3x because the block header on
31*f4a2713aSLionel Sambuc// LP64 consists of an isa pointer (which we're supposed to scan for
32*f4a2713aSLionel Sambuc// some reason) followed by three words (2 ints, a function pointer,
33*f4a2713aSLionel Sambuc// and a descriptor pointer).
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc// Test 1
36*f4a2713aSLionel Sambuc// Inline instruction for block variable layout: 0x0320 (3 strong 2 byref)
37*f4a2713aSLionel Sambuc// CHECK-LP64: Inline instruction for block variable layout: 0x0320
38*f4a2713aSLionel Sambuc    void (^b)() = ^{
39*f4a2713aSLionel Sambuc        byref_int = sh + ch+ch1+ch2 ;
40*f4a2713aSLionel Sambuc        x(bar);
41*f4a2713aSLionel Sambuc        x(baz);
42*f4a2713aSLionel Sambuc        x((id)strong_void_sta);
43*f4a2713aSLionel Sambuc        x(byref_bab);
44*f4a2713aSLionel Sambuc    };
45*f4a2713aSLionel Sambuc    b();
46*f4a2713aSLionel Sambuc
47*f4a2713aSLionel Sambuc// Test 2
48*f4a2713aSLionel Sambuc// Inline instruction for block variable layout: 0x0331 (3 strong 3 byref 1 weak)
49*f4a2713aSLionel Sambuc// CHECK-LP64: Inline instruction for block variable layout: 0x0331
50*f4a2713aSLionel Sambuc    void (^c)() = ^{
51*f4a2713aSLionel Sambuc        byref_int = sh + ch+ch1+ch2 ;
52*f4a2713aSLionel Sambuc        x(bar);
53*f4a2713aSLionel Sambuc        x(baz);
54*f4a2713aSLionel Sambuc        x((id)strong_void_sta);
55*f4a2713aSLionel Sambuc        x(wid);
56*f4a2713aSLionel Sambuc        bl_var1 = 0;
57*f4a2713aSLionel Sambuc        x(byref_bab);
58*f4a2713aSLionel Sambuc    };
59*f4a2713aSLionel Sambuc}
60*f4a2713aSLionel Sambuc
61*f4a2713aSLionel Sambuc@class NSString, NSNumber;
62*f4a2713aSLionel Sambucvoid g() {
63*f4a2713aSLionel Sambuc  NSString *foo;
64*f4a2713aSLionel Sambuc   NSNumber *bar;
65*f4a2713aSLionel Sambuc   unsigned int bletch;
66*f4a2713aSLionel Sambuc   __weak id weak_delegate;
67*f4a2713aSLionel Sambuc  unsigned int i;
68*f4a2713aSLionel Sambuc  NSString *y;
69*f4a2713aSLionel Sambuc  NSString *z;
70*f4a2713aSLionel Sambuc// Inline instruction for block variable layout: 0x0401 (4 strong 0 byref 1 weak)
71*f4a2713aSLionel Sambuc// CHECK-LP64: Inline instruction for block variable layout: 0x0401
72*f4a2713aSLionel Sambuc  void (^c)() = ^{
73*f4a2713aSLionel Sambuc   int j = i + bletch;
74*f4a2713aSLionel Sambuc   x(foo);
75*f4a2713aSLionel Sambuc   x(bar);
76*f4a2713aSLionel Sambuc   x(weak_delegate);
77*f4a2713aSLionel Sambuc   x(y);
78*f4a2713aSLionel Sambuc   x(z);
79*f4a2713aSLionel Sambuc  };
80*f4a2713aSLionel Sambuc  c();
81*f4a2713aSLionel Sambuc}
82*f4a2713aSLionel Sambuc
83*f4a2713aSLionel Sambuc// Test 5 (unions/structs and their nesting):
84*f4a2713aSLionel Sambucvoid h() {
85*f4a2713aSLionel Sambuc  struct S5 {
86*f4a2713aSLionel Sambuc    int i1;
87*f4a2713aSLionel Sambuc    __unsafe_unretained id o1;
88*f4a2713aSLionel Sambuc    struct V {
89*f4a2713aSLionel Sambuc     int i2;
90*f4a2713aSLionel Sambuc     __unsafe_unretained id o2;
91*f4a2713aSLionel Sambuc    } v1;
92*f4a2713aSLionel Sambuc    int i3;
93*f4a2713aSLionel Sambuc    union UI {
94*f4a2713aSLionel Sambuc        void * i1;
95*f4a2713aSLionel Sambuc        __unsafe_unretained id o1;
96*f4a2713aSLionel Sambuc        int i3;
97*f4a2713aSLionel Sambuc        __unsafe_unretained id o3;
98*f4a2713aSLionel Sambuc    }ui;
99*f4a2713aSLionel Sambuc  };
100*f4a2713aSLionel Sambuc
101*f4a2713aSLionel Sambuc  union U {
102*f4a2713aSLionel Sambuc        void * i1;
103*f4a2713aSLionel Sambuc        __unsafe_unretained id o1;
104*f4a2713aSLionel Sambuc        int i3;
105*f4a2713aSLionel Sambuc        __unsafe_unretained id o3;
106*f4a2713aSLionel Sambuc  }ui;
107*f4a2713aSLionel Sambuc
108*f4a2713aSLionel Sambuc  struct S5 s2;
109*f4a2713aSLionel Sambuc  union U u2;
110*f4a2713aSLionel Sambuc  __block id block_id;
111*f4a2713aSLionel Sambuc
112*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_BYREF:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0
113*f4a2713aSLionel Sambuc  void (^c)() = ^{
114*f4a2713aSLionel Sambuc    x(s2.ui.o1);
115*f4a2713aSLionel Sambuc    x(u2.o1);
116*f4a2713aSLionel Sambuc    block_id = 0;
117*f4a2713aSLionel Sambuc  };
118*f4a2713aSLionel Sambuc  c();
119*f4a2713aSLionel Sambuc}
120*f4a2713aSLionel Sambuc
121*f4a2713aSLionel Sambuc// Test for array of stuff.
122*f4a2713aSLionel Sambucvoid arr1() {
123*f4a2713aSLionel Sambuc  struct S {
124*f4a2713aSLionel Sambuc    __unsafe_unretained id unsafe_unretained_var[4];
125*f4a2713aSLionel Sambuc } imported_s;
126*f4a2713aSLionel Sambuc
127*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_UNRETAINED:4, BL_OPERATOR:0
128*f4a2713aSLionel Sambuc    void (^c)() = ^{
129*f4a2713aSLionel Sambuc        x(imported_s.unsafe_unretained_var[2]);
130*f4a2713aSLionel Sambuc    };
131*f4a2713aSLionel Sambuc
132*f4a2713aSLionel Sambuc   c();
133*f4a2713aSLionel Sambuc}
134*f4a2713aSLionel Sambuc
135*f4a2713aSLionel Sambuc// Test2 for array of stuff.
136*f4a2713aSLionel Sambucvoid arr2() {
137*f4a2713aSLionel Sambuc  struct S {
138*f4a2713aSLionel Sambuc   int a;
139*f4a2713aSLionel Sambuc    __unsafe_unretained id unsafe_unretained_var[4];
140*f4a2713aSLionel Sambuc } imported_s;
141*f4a2713aSLionel Sambuc
142*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINED:4, BL_OPERATOR:0
143*f4a2713aSLionel Sambuc    void (^c)() = ^{
144*f4a2713aSLionel Sambuc        x(imported_s.unsafe_unretained_var[2]);
145*f4a2713aSLionel Sambuc    };
146*f4a2713aSLionel Sambuc
147*f4a2713aSLionel Sambuc   c();
148*f4a2713aSLionel Sambuc}
149*f4a2713aSLionel Sambuc
150*f4a2713aSLionel Sambuc// Test3 for array of stuff.
151*f4a2713aSLionel Sambucvoid arr3() {
152*f4a2713aSLionel Sambuc  struct S {
153*f4a2713aSLionel Sambuc   int a;
154*f4a2713aSLionel Sambuc    __unsafe_unretained id unsafe_unretained_var[0];
155*f4a2713aSLionel Sambuc } imported_s;
156*f4a2713aSLionel Sambuc
157*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_OPERATOR:0
158*f4a2713aSLionel Sambuc    void (^c)() = ^{
159*f4a2713aSLionel Sambuc      int i = imported_s.a;
160*f4a2713aSLionel Sambuc    };
161*f4a2713aSLionel Sambuc
162*f4a2713aSLionel Sambuc   c();
163*f4a2713aSLionel Sambuc}
164*f4a2713aSLionel Sambuc
165*f4a2713aSLionel Sambuc
166*f4a2713aSLionel Sambuc// Test4 for array of stuff.
167*f4a2713aSLionel Sambuc@class B;
168*f4a2713aSLionel Sambucvoid arr4() {
169*f4a2713aSLionel Sambuc  struct S {
170*f4a2713aSLionel Sambuc    struct s0 {
171*f4a2713aSLionel Sambuc      __unsafe_unretained id s_f0;
172*f4a2713aSLionel Sambuc      __unsafe_unretained id s_f1;
173*f4a2713aSLionel Sambuc    } f0;
174*f4a2713aSLionel Sambuc
175*f4a2713aSLionel Sambuc    __unsafe_unretained id f1;
176*f4a2713aSLionel Sambuc
177*f4a2713aSLionel Sambuc    struct s1 {
178*f4a2713aSLionel Sambuc      int *f0;
179*f4a2713aSLionel Sambuc      __unsafe_unretained B *f1;
180*f4a2713aSLionel Sambuc    } f4[2][2];
181*f4a2713aSLionel Sambuc  } captured_s;
182*f4a2713aSLionel Sambuc
183*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_UNRETAINED:3, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0
184*f4a2713aSLionel Sambuc  void (^c)() = ^{
185*f4a2713aSLionel Sambuc      id i = captured_s.f0.s_f1;
186*f4a2713aSLionel Sambuc  };
187*f4a2713aSLionel Sambuc
188*f4a2713aSLionel Sambuc   c();
189*f4a2713aSLionel Sambuc}
190*f4a2713aSLionel Sambuc
191*f4a2713aSLionel Sambuc// Test1 bitfield in cpatured aggregate.
192*f4a2713aSLionel Sambucvoid bf1() {
193*f4a2713aSLionel Sambuc  struct S {
194*f4a2713aSLionel Sambuc    int flag : 25;
195*f4a2713aSLionel Sambuc    int flag1: 7;
196*f4a2713aSLionel Sambuc    int flag2 :1;
197*f4a2713aSLionel Sambuc    int flag3: 7;
198*f4a2713aSLionel Sambuc    int flag4: 24;
199*f4a2713aSLionel Sambuc  } s;
200*f4a2713aSLionel Sambuc
201*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_OPERATOR:0
202*f4a2713aSLionel Sambuc  int (^c)() = ^{
203*f4a2713aSLionel Sambuc      return s.flag;
204*f4a2713aSLionel Sambuc  };
205*f4a2713aSLionel Sambuc  c();
206*f4a2713aSLionel Sambuc}
207*f4a2713aSLionel Sambuc
208*f4a2713aSLionel Sambuc// Test2 bitfield in cpatured aggregate.
209*f4a2713aSLionel Sambucvoid bf2() {
210*f4a2713aSLionel Sambuc  struct S {
211*f4a2713aSLionel Sambuc    int flag : 1;
212*f4a2713aSLionel Sambuc  } s;
213*f4a2713aSLionel Sambuc
214*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_OPERATOR:0
215*f4a2713aSLionel Sambuc  int (^c)() = ^{
216*f4a2713aSLionel Sambuc      return s.flag;
217*f4a2713aSLionel Sambuc  };
218*f4a2713aSLionel Sambuc  c();
219*f4a2713aSLionel Sambuc}
220*f4a2713aSLionel Sambuc
221*f4a2713aSLionel Sambuc// Test3 bitfield in cpatured aggregate.
222*f4a2713aSLionel Sambucvoid bf3() {
223*f4a2713aSLionel Sambuc
224*f4a2713aSLionel Sambuc     struct {
225*f4a2713aSLionel Sambuc        unsigned short _reserved : 16;
226*f4a2713aSLionel Sambuc
227*f4a2713aSLionel Sambuc        unsigned char _draggedNodesAreDeletable: 1;
228*f4a2713aSLionel Sambuc        unsigned char _draggedOutsideOutlineView : 1;
229*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_addRootPaths : 1;
230*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_moveDataNodes : 1;
231*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_removeRootDataNode : 1;
232*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_doubleClickDataNode : 1;
233*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_selectDataNode : 1;
234*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_textDidEndEditing : 1;
235*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_updateAndSaveRoots : 1;
236*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_askToDeleteRootNodes : 1;
237*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_contextMenuForSelectedNodes : 1;
238*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
239*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_writeItemsToPasteboard : 1;
240*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
241*f4a2713aSLionel Sambuc
242*f4a2713aSLionel Sambuc        unsigned int _filler : 32;
243*f4a2713aSLionel Sambuc    } _flags;
244*f4a2713aSLionel Sambuc
245*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_OPERATOR:0
246*f4a2713aSLionel Sambuc  unsigned char (^c)() = ^{
247*f4a2713aSLionel Sambuc      return _flags._draggedNodesAreDeletable;
248*f4a2713aSLionel Sambuc  };
249*f4a2713aSLionel Sambuc
250*f4a2713aSLionel Sambuc   c();
251*f4a2713aSLionel Sambuc}
252*f4a2713aSLionel Sambuc
253*f4a2713aSLionel Sambuc// Test4 unnamed bitfield
254*f4a2713aSLionel Sambucvoid bf4() {
255*f4a2713aSLionel Sambuc
256*f4a2713aSLionel Sambuc     struct {
257*f4a2713aSLionel Sambuc        unsigned short _reserved : 16;
258*f4a2713aSLionel Sambuc
259*f4a2713aSLionel Sambuc        unsigned char _draggedNodesAreDeletable: 1;
260*f4a2713aSLionel Sambuc        unsigned char _draggedOutsideOutlineView : 1;
261*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_addRootPaths : 1;
262*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_moveDataNodes : 1;
263*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_removeRootDataNode : 1;
264*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_doubleClickDataNode : 1;
265*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_selectDataNode : 1;
266*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_textDidEndEditing : 1;
267*f4a2713aSLionel Sambuc
268*f4a2713aSLionel Sambuc        unsigned long long : 64;
269*f4a2713aSLionel Sambuc
270*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_updateAndSaveRoots : 1;
271*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_askToDeleteRootNodes : 1;
272*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_contextMenuForSelectedNodes : 1;
273*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
274*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_writeItemsToPasteboard : 1;
275*f4a2713aSLionel Sambuc        unsigned char _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
276*f4a2713aSLionel Sambuc
277*f4a2713aSLionel Sambuc        unsigned int _filler : 32;
278*f4a2713aSLionel Sambuc    } _flags;
279*f4a2713aSLionel Sambuc
280*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_OPERATOR:0
281*f4a2713aSLionel Sambuc  unsigned char (^c)() = ^{
282*f4a2713aSLionel Sambuc      return _flags._draggedNodesAreDeletable;
283*f4a2713aSLionel Sambuc  };
284*f4a2713aSLionel Sambuc
285*f4a2713aSLionel Sambuc   c();
286*f4a2713aSLionel Sambuc}
287*f4a2713aSLionel Sambuc
288*f4a2713aSLionel Sambuc
289*f4a2713aSLionel Sambuc
290*f4a2713aSLionel Sambuc// Test5 unnamed bitfield.
291*f4a2713aSLionel Sambucvoid bf5() {
292*f4a2713aSLionel Sambuc     struct {
293*f4a2713aSLionel Sambuc        unsigned char flag : 1;
294*f4a2713aSLionel Sambuc        unsigned int  : 32;
295*f4a2713aSLionel Sambuc        unsigned char flag1 : 1;
296*f4a2713aSLionel Sambuc    } _flags;
297*f4a2713aSLionel Sambuc
298*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_OPERATOR:0
299*f4a2713aSLionel Sambuc  unsigned char (^c)() = ^{
300*f4a2713aSLionel Sambuc      return _flags.flag;
301*f4a2713aSLionel Sambuc  };
302*f4a2713aSLionel Sambuc
303*f4a2713aSLionel Sambuc   c();
304*f4a2713aSLionel Sambuc}
305*f4a2713aSLionel Sambuc
306*f4a2713aSLionel Sambuc
307*f4a2713aSLionel Sambuc// Test6 0 length bitfield.
308*f4a2713aSLionel Sambucvoid bf6() {
309*f4a2713aSLionel Sambuc     struct {
310*f4a2713aSLionel Sambuc        unsigned char flag : 1;
311*f4a2713aSLionel Sambuc        unsigned int  : 0;
312*f4a2713aSLionel Sambuc        unsigned char flag1 : 1;
313*f4a2713aSLionel Sambuc    } _flags;
314*f4a2713aSLionel Sambuc
315*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_OPERATOR:0
316*f4a2713aSLionel Sambuc  unsigned char (^c)() = ^{
317*f4a2713aSLionel Sambuc      return _flags.flag;
318*f4a2713aSLionel Sambuc  };
319*f4a2713aSLionel Sambuc
320*f4a2713aSLionel Sambuc   c();
321*f4a2713aSLionel Sambuc}
322*f4a2713aSLionel Sambuc
323*f4a2713aSLionel Sambuc// Test7 large number of captured variables.
324*f4a2713aSLionel Sambucvoid Test7() {
325*f4a2713aSLionel Sambuc    __weak id wid;
326*f4a2713aSLionel Sambuc    __weak id wid1, wid2, wid3, wid4;
327*f4a2713aSLionel Sambuc    __weak id wid5, wid6, wid7, wid8;
328*f4a2713aSLionel Sambuc    __weak id wid9, wid10, wid11, wid12;
329*f4a2713aSLionel Sambuc    __weak id wid13, wid14, wid15, wid16;
330*f4a2713aSLionel Sambuc    const id bar = (id) opaque_id();
331*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_STRONG:1, BL_WEAK:16, BL_OPERATOR:0
332*f4a2713aSLionel Sambuc    void (^b)() = ^{
333*f4a2713aSLionel Sambuc      x(bar);
334*f4a2713aSLionel Sambuc      x(wid1);
335*f4a2713aSLionel Sambuc      x(wid2);
336*f4a2713aSLionel Sambuc      x(wid3);
337*f4a2713aSLionel Sambuc      x(wid4);
338*f4a2713aSLionel Sambuc      x(wid5);
339*f4a2713aSLionel Sambuc      x(wid6);
340*f4a2713aSLionel Sambuc      x(wid7);
341*f4a2713aSLionel Sambuc      x(wid8);
342*f4a2713aSLionel Sambuc      x(wid9);
343*f4a2713aSLionel Sambuc      x(wid10);
344*f4a2713aSLionel Sambuc      x(wid11);
345*f4a2713aSLionel Sambuc      x(wid12);
346*f4a2713aSLionel Sambuc      x(wid13);
347*f4a2713aSLionel Sambuc      x(wid14);
348*f4a2713aSLionel Sambuc      x(wid15);
349*f4a2713aSLionel Sambuc      x(wid16);
350*f4a2713aSLionel Sambuc    };
351*f4a2713aSLionel Sambuc}
352*f4a2713aSLionel Sambuc
353*f4a2713aSLionel Sambuc
354*f4a2713aSLionel Sambuc// Test 8 very large number of captured variables.
355*f4a2713aSLionel Sambucvoid Test8() {
356*f4a2713aSLionel Sambuc__weak id wid;
357*f4a2713aSLionel Sambuc    __weak id wid1, wid2, wid3, wid4;
358*f4a2713aSLionel Sambuc    __weak id wid5, wid6, wid7, wid8;
359*f4a2713aSLionel Sambuc    __weak id wid9, wid10, wid11, wid12;
360*f4a2713aSLionel Sambuc    __weak id wid13, wid14, wid15, wid16;
361*f4a2713aSLionel Sambuc    __weak id w1, w2, w3, w4;
362*f4a2713aSLionel Sambuc    __weak id w5, w6, w7, w8;
363*f4a2713aSLionel Sambuc    __weak id w9, w10, w11, w12;
364*f4a2713aSLionel Sambuc    __weak id w13, w14, w15, w16;
365*f4a2713aSLionel Sambuc    const id bar = (id) opaque_id();
366*f4a2713aSLionel Sambuc// CHECK-LP64: block variable layout: BL_STRONG:1, BL_WEAK:16, BL_WEAK:16, BL_WEAK:1, BL_OPERATOR:0
367*f4a2713aSLionel Sambuc    void (^b)() = ^{
368*f4a2713aSLionel Sambuc      x(bar);
369*f4a2713aSLionel Sambuc      x(wid1);
370*f4a2713aSLionel Sambuc      x(wid2);
371*f4a2713aSLionel Sambuc      x(wid3);
372*f4a2713aSLionel Sambuc      x(wid4);
373*f4a2713aSLionel Sambuc      x(wid5);
374*f4a2713aSLionel Sambuc      x(wid6);
375*f4a2713aSLionel Sambuc      x(wid7);
376*f4a2713aSLionel Sambuc      x(wid8);
377*f4a2713aSLionel Sambuc      x(wid9);
378*f4a2713aSLionel Sambuc      x(wid10);
379*f4a2713aSLionel Sambuc      x(wid11);
380*f4a2713aSLionel Sambuc      x(wid12);
381*f4a2713aSLionel Sambuc      x(wid13);
382*f4a2713aSLionel Sambuc      x(wid14);
383*f4a2713aSLionel Sambuc      x(wid15);
384*f4a2713aSLionel Sambuc      x(wid16);
385*f4a2713aSLionel Sambuc      x(w1);
386*f4a2713aSLionel Sambuc      x(w2);
387*f4a2713aSLionel Sambuc      x(w3);
388*f4a2713aSLionel Sambuc      x(w4);
389*f4a2713aSLionel Sambuc      x(w5);
390*f4a2713aSLionel Sambuc      x(w6);
391*f4a2713aSLionel Sambuc      x(w7);
392*f4a2713aSLionel Sambuc      x(w8);
393*f4a2713aSLionel Sambuc      x(w9);
394*f4a2713aSLionel Sambuc      x(w10);
395*f4a2713aSLionel Sambuc      x(w11);
396*f4a2713aSLionel Sambuc      x(w12);
397*f4a2713aSLionel Sambuc      x(w13);
398*f4a2713aSLionel Sambuc      x(w14);
399*f4a2713aSLionel Sambuc      x(w15);
400*f4a2713aSLionel Sambuc      x(w16);
401*f4a2713aSLionel Sambuc      x(wid);
402*f4a2713aSLionel Sambuc    };
403*f4a2713aSLionel Sambuc}
404