+2016-05-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/71105
+ * g++.dg/cpp0x/lambda/lambda-conv11.C: New.
+ * g++.dg/cpp1y/lambda-conv1.C: Likewise.
+ * g++.dg/cpp1y/lambda-conv2.C: Likewise.
+
2016-05-27 Jan Hubicka <hubicka@ucw.cz>
* gcc.dg/tree-ssa/prefetch-5.c: Remove xfail.
--- /dev/null
+// PR c++/71105
+// { dg-do compile { target c++11 } }
+
+void foo()
+{
+ int i;
+ static_cast<void(*)()>([i]{}); // { dg-error "invalid static_cast" }
+ static_cast<void(*)()>([=]{}); // { dg-error "invalid static_cast" }
+ static_cast<void(*)()>([&]{}); // { dg-error "invalid static_cast" }
+}
--- /dev/null
+// PR c++/71105
+// { dg-do compile { target c++14 } }
+
+void foo()
+{
+ int i;
+ static_cast<void(*)(int)>([i](auto){}); // { dg-error "invalid static_cast" }
+ static_cast<void(*)(int)>([=](auto){}); // { dg-error "invalid static_cast" }
+ static_cast<void(*)(int)>([&](auto){}); // { dg-error "invalid static_cast" }
+ static_cast<float(*)(float)>([i](auto x){ return x; }); // { dg-error "invalid static_cast" }
+ static_cast<float(*)(float)>([=](auto x){ return x; }); // { dg-error "invalid static_cast" }
+ static_cast<float(*)(float)>([&](auto x){ return x; }); // { dg-error "invalid static_cast" }
+}
--- /dev/null
+// PR c++/71105
+// { dg-do compile { target c++14 } }
+
+template <typename T> T declval();
+template <typename, typename> struct is_same
+{ static constexpr bool value = false; };
+template <typename T> struct is_same<T, T>
+{ static constexpr bool value = true; };
+
+template <class F>
+struct indirected : F {
+ indirected(F f) : F(f) {}
+ template <class I>
+ auto operator()(I i) -> decltype(declval<F&>()(*i)) {
+ return static_cast<F&>(*this)(*i);
+ }
+};
+
+int main() {
+ auto f = [=](auto i) { return i + i; };
+ auto i = indirected<decltype(f)>{f};
+ static_assert(is_same<decltype(i(declval<int*>())), int>::value, "");
+}