summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2012-09-10 23:51:34 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2012-09-10 23:51:34 +0000
commit85c0e76827d9597528b0f32d5e8742733a4ab781 (patch)
tree371dbd5d363efdc35936b80cbdf15ac707793a58 /gcc
parentd98d1ee5e9d020b8f51ce30e64accd8ba16bc3ea (diff)
downloadgcc-85c0e76827d9597528b0f32d5e8742733a4ab781.tar.gz
PR c++/54538
PR c++/53783 * pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Go back to using RECUR for LAMBDA_EXPR_EXTRA_SCOPE except for function scope. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191164 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle4.C13
4 files changed, 35 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2fd7c1242b0..72e6c512a64 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2012-09-10 Jason Merrill <jason@redhat.com>
+ PR c++/54538
+ PR c++/53783
+ * pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Go back to using RECUR
+ for LAMBDA_EXPR_EXTRA_SCOPE except for function scope.
+
PR c++/54506
* decl.c (move_signature_fn_p): Split out from move_fn_p.
* method.c (process_subob_fn): Use it.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cde83f2d953..a87552827a9 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -14199,8 +14199,18 @@ tsubst_copy_and_build (tree t,
LAMBDA_EXPR_MUTABLE_P (r) = LAMBDA_EXPR_MUTABLE_P (t);
LAMBDA_EXPR_DISCRIMINATOR (r)
= (LAMBDA_EXPR_DISCRIMINATOR (t));
- LAMBDA_EXPR_EXTRA_SCOPE (r)
- = tsubst (LAMBDA_EXPR_EXTRA_SCOPE (t), args, complain, in_decl);
+ /* For a function scope, we want to use tsubst so that we don't
+ complain about referring to an auto function before its return
+ type has been deduced. Otherwise, we want to use tsubst_copy so
+ that we look up the existing field/parameter/variable rather
+ than build a new one. */
+ tree scope = LAMBDA_EXPR_EXTRA_SCOPE (t);
+ if (scope && TREE_CODE (scope) == FUNCTION_DECL)
+ scope = tsubst (LAMBDA_EXPR_EXTRA_SCOPE (t), args,
+ complain, in_decl);
+ 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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1f8edec5b6d..bd147805cbc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-10 Jason Merrill <jason@redhat.com>
+
+ PR c++/54538
+ * g++.dg/cpp0x/lambda/lambda-mangle4.C: New.
+
2012-09-10 Oleg Endo <olegendo@gcc.gnu.org>
PR target/54089
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle4.C
new file mode 100644
index 00000000000..0d37637fe9c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle4.C
@@ -0,0 +1,13 @@
+// PR c++/54538
+// { dg-do compile { target c++11 } }
+
+template <class T>
+struct A
+{
+ // { dg-final { scan-assembler "_ZNK1AIcE1pMUlvE_cvPFvvEEv" } }
+ // { dg-final { scan-assembler "_ZNK1AIiE1pMUlvE_cvPFvvEEv" } }
+ void (*p)() = []{};
+};
+
+A<int> a1;
+A<char> a2;