pt.c (tsubst_copy_and_build): Get LAMBDA_EXPR_RETURN_TYPE from the instantiated closure.

* pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Get
	LAMBDA_EXPR_RETURN_TYPE from the instantiated closure.

From-SVN: r233955
This commit is contained in:
Jason Merrill 2016-03-03 20:45:48 -05:00 committed by Jason Merrill
parent 264fd1424e
commit a0a6a8c966
3 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,8 @@
2016-03-03 Jason Merrill <jason@redhat.com>
* pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Get
LAMBDA_EXPR_RETURN_TYPE from the instantiated closure.
PR c++/67164
* pt.c (copy_template_args): New.
(tsubst_pack_expansion): Use it.

View File

@ -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 ();

View File

@ -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>();
}