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.

llvm-svn: 150645
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
index 0806828..3301b29 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.cpp
@@ -13,3 +13,23 @@
   const auto lambda = [=](int x) { return x + captured; };
   int (^b2)(int) = lambda;
 }
+
+template<typename T>
+class ConstCopyConstructorBoom {
+public:
+  ConstCopyConstructorBoom(ConstCopyConstructorBoom&);
+
+  ConstCopyConstructorBoom(const ConstCopyConstructorBoom&) {
+    T *ptr = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}}
+  }
+
+  void foo() const;
+};
+
+void conversion_to_block_init(ConstCopyConstructorBoom<int> boom,
+                              ConstCopyConstructorBoom<float> boom2) {
+  const auto& lambda1([=] { boom.foo(); }); // okay
+
+  const auto& lambda2([=] { boom2.foo(); }); // expected-note{{in instantiation of member function}}
+  void (^block)(void) = lambda2;
+}