This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/42399 (ICE with lambdas)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 09 Feb 2010 17:07:55 -0500
- Subject: C++ PATCH for c++/42399 (ICE with lambdas)
Forgot to copy LAMBDA_EXPR_LOCATION, so we were ending up with null
input_location and crashing when trying to make a class type.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit ea05b1df0accd45524907c5740ac894e43144073
Author: Jason Merrill <jason@redhat.com>
Date: Tue Feb 9 16:07:29 2010 -0500
PR c++/42399
* pt.c (tsubst_copy_and_build): Propagate LAMBDA_EXPR_LOCATION.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b903f77..1327d54 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12674,6 +12674,8 @@ tsubst_copy_and_build (tree t,
TREE_TYPE (r) = type;
CLASSTYPE_LAMBDA_EXPR (type) = r;
+ LAMBDA_EXPR_LOCATION (r)
+ = LAMBDA_EXPR_LOCATION (t);
LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (r)
= LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (t);
LAMBDA_EXPR_MUTABLE_P (r) = LAMBDA_EXPR_MUTABLE_P (t);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc2.C
new file mode 100644
index 0000000..3d53c13
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc2.C
@@ -0,0 +1,19 @@
+// PR c++/42399
+// { dg-options "-std=c++0x" }
+
+struct A {
+ A();
+ A(const A&) = delete; // { dg-error "deleted function" }
+};
+
+template <class T>
+void f()
+{
+ T t;
+ [t] { return 0; }; // { dg-error "used here" }
+}
+
+int main()
+{
+ f<A>(); // { dg-message "instantiated" }
+}