xref: /minix3/external/bsd/llvm/dist/clang/test/Rewriter/rewrite-captured-nested-bvar.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -x c -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
2*f4a2713aSLionel Sambuc // RUN: FileCheck --input-file=%t-rw.cpp %s
3*f4a2713aSLionel Sambuc // rdar://9006279
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc void q(void (^p)(void)) {
6*f4a2713aSLionel Sambuc     p();
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
f()9*f4a2713aSLionel Sambuc void f() {
10*f4a2713aSLionel Sambuc     __block char BYREF_VAR_CHECK = 'a';
11*f4a2713aSLionel Sambuc     __block char d = 'd';
12*f4a2713aSLionel Sambuc     q(^{
13*f4a2713aSLionel Sambuc         q(^{
14*f4a2713aSLionel Sambuc             __block char e = 'e';
15*f4a2713aSLionel Sambuc             char l = 'l';
16*f4a2713aSLionel Sambuc             BYREF_VAR_CHECK = 'b';
17*f4a2713aSLionel Sambuc             d = 'd';
18*f4a2713aSLionel Sambuc             q(^{
19*f4a2713aSLionel Sambuc                  e = '1';
20*f4a2713aSLionel Sambuc                  BYREF_VAR_CHECK = '2';
21*f4a2713aSLionel Sambuc                  d = '3';
22*f4a2713aSLionel Sambuc                }
23*f4a2713aSLionel Sambuc              );
24*f4a2713aSLionel Sambuc         });
25*f4a2713aSLionel Sambuc     });
26*f4a2713aSLionel Sambuc }
27*f4a2713aSLionel Sambuc 
main()28*f4a2713aSLionel Sambuc int main() {
29*f4a2713aSLionel Sambuc     f();
30*f4a2713aSLionel Sambuc     return 0;
31*f4a2713aSLionel Sambuc }
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc // CHECK 2: (__Block_byref_BYREF_VAR_CHECK_0 *)BYREF_VAR_CHECK
34*f4a2713aSLionel Sambuc // CHECK: (__Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK
35*f4a2713aSLionel Sambuc // CHECK: (struct __Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, (struct __Block_byref_d_1 *)&d, 570425344));
36