This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/51415 (vec_init_expr not handled by dump_expr)


Lambda closure object initialization uses VEC_INIT_EXPR to express array copy, which confused dump_expr. But there's no reason to print out the details of that initialization at all; we should just say "closure object" and be done with it.

Of course, this is another instance of problems with printing the internal expression representation rather than the source form...

Tested x86_64-pc-linux-gnu, applied to trunk
commit 25a7d8c9be6a926081d2a0460984366fa49bbe22
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Feb 16 10:28:57 2012 -0800

    	PR c++/51415
    	* error.c (dump_expr): Handle lambda closures specifically.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 09c6cae..4ec263b 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -2189,6 +2189,8 @@ dump_expr (tree t, int flags)
 		}
 	    }
 	}
+      if (TREE_TYPE (t) && LAMBDA_TYPE_P (TREE_TYPE (t)))
+	pp_string (cxx_pp, "<lambda closure object>");
       if (TREE_TYPE (t) && EMPTY_CONSTRUCTOR_P (t))
 	{
 	  dump_type (TREE_TYPE (t), 0);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-err1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-err1.C
new file mode 100644
index 0000000..ebf0cbd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-err1.C
@@ -0,0 +1,8 @@
+// PR c++/51415
+// { dg-do compile { target c++11 } }
+
+void foo()
+{
+  int x[1];
+  [x]{} = 0;			// { dg-error "lambda closure" }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]