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 to cp_parser_lambda_expression


No need to obfuscate __this, as it's already obfuscated.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 2ec4e7f5792d1de1f17c495a28e9b23529143ed6
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Sep 30 10:52:57 2009 -0400

    	* parser.c (cp_parser_lambda_expression): Don't add __ to __this.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 84cdef4..deded00 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -7077,21 +7077,26 @@ cp_parser_lambda_expression (cp_parser* parser)
       for (elt = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr);
 	   elt; elt = next)
 	{
+	  tree field = TREE_PURPOSE (elt);
+	  char *buf;
+
+	  next = TREE_CHAIN (elt);
+	  TREE_CHAIN (elt) = newlist;
+	  newlist = elt;
+
 	  /* Also add __ to the beginning of the field name so that code
 	     outside the lambda body can't see the captured name.  We could
 	     just remove the name entirely, but this is more useful for
 	     debugging.  */
-	  tree field = TREE_PURPOSE (elt);
-	  char *buf
-	    = (char *) alloca (IDENTIFIER_LENGTH (DECL_NAME (field)) + 3);
+	  if (field == LAMBDA_EXPR_THIS_CAPTURE (lambda_expr))
+	    /* The 'this' capture already starts with __.  */
+	    continue;
+
+	  buf = (char *) alloca (IDENTIFIER_LENGTH (DECL_NAME (field)) + 3);
 	  buf[1] = buf[0] = '_';
 	  memcpy (buf + 2, IDENTIFIER_POINTER (DECL_NAME (field)),
 		  IDENTIFIER_LENGTH (DECL_NAME (field)) + 1);
 	  DECL_NAME (field) = get_identifier (buf);
-
-	  next = TREE_CHAIN (elt);
-	  TREE_CHAIN (elt) = newlist;
-	  newlist = elt;
 	}
       LAMBDA_EXPR_CAPTURE_LIST (lambda_expr) = newlist;
     }


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