summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-15 17:03:58 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-15 17:03:58 +0000
commitd187f84169ad200a7e45e27994453adad4543ec7 (patch)
treee4c2c1a8ff1aa3b1bd47832489efc0f187244aa0
parentc7257146a2339cb903ac97949593acd3b14095ce (diff)
downloadlinaro-gcc-d187f84169ad200a7e45e27994453adad4543ec7.tar.gz
linaro-gcc-d187f84169ad200a7e45e27994453adad4543ec7.tar.bz2
linaro-gcc-d187f84169ad200a7e45e27994453adad4543ec7.zip
* pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Get
LAMBDA_EXPR_RETURN_TYPE from the instantiated closure. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-5-branch@235044 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c5
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/lambda-generic-trailing1.C12
3 files changed, 18 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ab310579d38..48a958606b4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2016-04-15 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.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 92ba2f2687f..9478f24e877 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15901,8 +15901,6 @@ tsubst_copy_and_build (tree t,
else
scope = RECUR (scope);
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);
@@ -15913,6 +15911,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 ();
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-trailing1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-trailing1.C
new file mode 100644
index 00000000000..96755b11fd8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-trailing1.C
@@ -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>();
+}