Patchwork [C++] PR 51412

login
register
mail settings
Submitter Paolo Carlini
Date March 8, 2013, 11:27 a.m.
Message ID <5139CB3D.90201@oracle.com>
Download mbox | patch
Permalink /patch/226090/
State New
Headers show

Comments

Paolo Carlini - March 8, 2013, 11:27 a.m.
Hi,

today I noticed that I still have assigned this rather simple diagnostic 
issue, where LAMBDA_EXPR is unhandled by our pretty printing code. I 
suppose we can make at least some progress for 4.8.0. Is the below goo 
enough for now?

Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////
/cp
2013-03-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51412
	* cxx-pretty-print.c (pp_cxx_expression): Handle LAMBDA_EXPR.
	* error.c (dump_expr): Likewise.

/testsuite
2013-03-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51412
	* g++.dg/cpp0x/lambda/lambda-err3.C: New.
Jason Merrill - March 8, 2013, 3:09 p.m.
OK.

Jason

Patch

Index: cp/cxx-pretty-print.c
===================================================================
--- cp/cxx-pretty-print.c	(revision 196540)
+++ cp/cxx-pretty-print.c	(working copy)
@@ -1162,6 +1162,10 @@  pp_cxx_expression (cxx_pretty_printer *pp, tree t)
 	  }
       }
       break;
+      
+    case LAMBDA_EXPR:
+      pp_cxx_ws_string (pp, "<lambda>");
+      break;
 
     default:
       pp_c_expression (pp_c_base (pp), t);
Index: cp/error.c
===================================================================
--- cp/error.c	(revision 196540)
+++ cp/error.c	(working copy)
@@ -2494,6 +2494,10 @@  dump_expr (tree t, int flags)
       dump_expr (resolve_virtual_fun_from_obj_type_ref (t), flags);
       break;
 
+    case LAMBDA_EXPR:
+      pp_string (cxx_pp, M_("<lambda>"));
+      break;
+
       /*  This list is incomplete, but should suffice for now.
 	  It is very important that `sorry' does not call
 	  `report_error_function'.  That could cause an infinite loop.  */
Index: testsuite/g++.dg/cpp0x/lambda/lambda-err3.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-err3.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-err3.C	(working copy)
@@ -0,0 +1,10 @@ 
+// PR c++/51412
+// { dg-do compile { target c++11 } }
+
+void foo(int);
+
+template<int> void bar()
+{
+  foo([]{}...);      // { dg-error "<lambda>" }
+  foo([]{}=0 ...);   // { dg-error "<lambda>" }
+}