diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-16 01:06:16 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-16 01:06:16 +0000 |
commit | f6e2e0291b8964ed41b4325e21dd90b86e791f10 (patch) | |
tree | c630fad2fe486d3f2d2d3cfd815937fd52e71dd8 /test/PCH | |
parent | b49bd27b334a6c4e3bf9d810a7d5b022578f1194 (diff) |
Implicitly define a lambda's conversion functions (to function
pointers and block pointers). We use dummy definitions to keep the
invariant that an implicit, used definition has a body; IR generation
will substitute the actual contents, since they can't be represented
as C++.
For the block pointer case, compute the copy-initialization needed to
capture the lambda object in the block, which IR generation will need
later.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/cxx11-lambdas.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/test/PCH/cxx11-lambdas.cpp b/test/PCH/cxx11-lambdas.cpp index cc17099f01..c00ec63807 100644 --- a/test/PCH/cxx11-lambdas.cpp +++ b/test/PCH/cxx11-lambdas.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t-cxx11 -// RUN: %clang_cc1 -ast-print -pedantic-errors -std=c++11 -include-pch %t-cxx11 %s | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: %clang_cc1 -pedantic-errors -fblocks -std=c++11 -emit-pch %s -o %t-cxx11 +// RUN: %clang_cc1 -ast-print -pedantic-errors -fblocks -std=c++11 -include-pch %t-cxx11 %s | FileCheck -check-prefix=CHECK-PRINT %s #ifndef HEADER_INCLUDED @@ -26,6 +26,13 @@ inline int sum_array(int n) { return lambda(n); } + +inline int to_block_pointer(int n) { + auto lambda = [=](int m) { return n + m; }; + int (^block)(int) = lambda; + return block(17); +} + #else // CHECK-PRINT: T add_slowly @@ -33,7 +40,7 @@ inline int sum_array(int n) { template float add_slowly(const float&, const float&); int add(int x, int y) { - return add_int_slowly_twice(x, y) + sum_array(4); + return add_int_slowly_twice(x, y) + sum_array(4) + to_block_pointer(5); } // CHECK-PRINT: inline int add_int_slowly_twice |