blob: 9f9867106930beb77582680d214c5400982b76ae [file] [log] [blame]
Douglas Gregora8182f92012-05-16 17:01:33 +00001// RUN: %clang_cc1 -std=c++11 -fblocks -emit-llvm -o - -triple x86_64-apple-darwin11.3 %s | FileCheck %s
2
3namespace PR12746 {
4 // CHECK: define zeroext i1 @_ZN7PR127462f1EPi
5 bool f1(int *x) {
Fariborz Jahanian63628032012-06-26 16:06:38 +00006 // CHECK: store i8* bitcast (i1 (i8*)* @___ZN7PR127462f1EPi_block_invoke to i8*)
Douglas Gregora8182f92012-05-16 17:01:33 +00007 bool (^outer)() = ^ {
8 auto inner = [&]() -> bool {
9 return x == 0;
10 };
11 return inner();
12 };
13 return outer();
14 }
15
Fariborz Jahanian63628032012-06-26 16:06:38 +000016 // CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke
17 // CHECK: call zeroext i1 @"_ZNK7PR127462f132___ZN7PR127462f1EPi_block_invoke3$_0clEv"
Douglas Gregora8182f92012-05-16 17:01:33 +000018
19 bool f2(int *x) {
20 auto outer = [&]() -> bool {
21 bool (^inner)() = ^ {
22 return x == 0;
23 };
24 return inner();
25 };
26 return outer();
27 }
28}
29