xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/reference-in-block-args.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fblocks %s -emit-llvm -o %t
2*f4a2713aSLionel Sambuc // rdar: // 8041962
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc extern "C" int printf(const char*, ...);
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc struct ST {
7*f4a2713aSLionel Sambuc      int filler;
8*f4a2713aSLionel Sambuc      int referrer;
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc void OUTER_BLOCK(void (^fixer)(ST& ref)) {
12*f4a2713aSLionel Sambuc     ST ref = {2, 100};
13*f4a2713aSLionel Sambuc     fixer(ref);
14*f4a2713aSLionel Sambuc }
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc void INNER_BLOCK(int (^largeDo) ()) {
17*f4a2713aSLionel Sambuc 	printf("%d\n", largeDo());
18*f4a2713aSLionel Sambuc }
19*f4a2713aSLionel Sambuc 
scan()20*f4a2713aSLionel Sambuc void scan() {
21*f4a2713aSLionel Sambuc             OUTER_BLOCK(^(ST &ref) {
22*f4a2713aSLionel Sambuc                 INNER_BLOCK(^() { return ref.referrer + ref.filler; });
23*f4a2713aSLionel Sambuc             });
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
main()27*f4a2713aSLionel Sambuc int main() {
28*f4a2713aSLionel Sambuc     scan();
29*f4a2713aSLionel Sambuc }
30