commit 178af5b2e30a6efb8e49638c37dfea7320586c62
Author: Jason Merrill <jason@redhat.com>
Date: Wed Mar 2 14:53:31 2016 -0500
* pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Get
LAMBDA_EXPR_RETURN_TYPE from the instantiated closure.
@@ -17103,8 +17103,6 @@ tsubst_copy_and_build (tree t,
else
gcc_unreachable ();
LAMBDA_EXPR_EXTRA_SCOPE (r) = scope;
- LAMBDA_EXPR_RETURN_TYPE (r)
- = tsubst (LAMBDA_EXPR_RETURN_TYPE (t), args, complain, in_decl);
gcc_assert (LAMBDA_EXPR_THIS_CAPTURE (t) == NULL_TREE
&& LAMBDA_EXPR_PENDING_PROXIES (t) == NULL);
@@ -17115,6 +17113,9 @@ tsubst_copy_and_build (tree t,
declaration of the op() for later calls to lambda_function. */
complete_type (type);
+ if (tree fn = lambda_function (type))
+ LAMBDA_EXPR_RETURN_TYPE (r) = TREE_TYPE (TREE_TYPE (fn));
+
LAMBDA_EXPR_THIS_CAPTURE (r) = NULL_TREE;
insert_pending_capture_proxies ();
new file mode 100644
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++14 } }
+
+template <class T>
+void f()
+{
+ auto lam = [](auto a)->decltype(++a) { return a; };
+}
+
+int main()
+{
+ f<int>();
+}