aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-15 22:08:38 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-15 22:08:38 +0000
commitc2956e5681113bbcec5ff98833345166942a211b (patch)
tree51bb5ee8760a04157f980ca613bba0e6609fd0b1 /test
parent4339bb3a71b6463415708553fda16aa7e44d07eb (diff)
Lambda closure types have a conversion function to a block pointer
with the same parameter types and return type as the function call operator. This is the real answer to http://stackoverflow.com/questions/4148242/is-it-possible-to-convert-a-c0x-lambda-to-a-clang-block :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
index ba2b70e4c3..0806828c83 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
@@ -6,3 +6,10 @@ void block_capture_errors() {
(void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
}
+
+void conversion_to_block(int captured) {
+ int (^b1)(int) = [=](int x) { return x + captured; };
+
+ const auto lambda = [=](int x) { return x + captured; };
+ int (^b2)(int) = lambda;
+}