diff options
author | Jason Merrill <jason@redhat.com> | 2009-09-30 11:49:24 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-09-30 11:49:24 -0400 |
commit | 23823e0a4e7c4f7075f512b6d38fcd634adbab2a (patch) | |
tree | bf44875e3be200ca784ead2087067b0e5c918a02 | |
parent | bfd6b23c4f733584abc55de79b10d575fc87152d (diff) | |
download | gcc-23823e0a4e7c4f7075f512b6d38fcd634adbab2a.zip gcc-23823e0a4e7c4f7075f512b6d38fcd634adbab2a.tar.gz gcc-23823e0a4e7c4f7075f512b6d38fcd634adbab2a.tar.bz2 |
* parser.c (cp_parser_lambda_expression): Don't add __ to __this.
From-SVN: r152330
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/parser.c | 19 |
2 files changed, 16 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 03cbb28..ae162d4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2009-09-30 Jason Merrill <jason@redhat.com> + * parser.c (cp_parser_lambda_expression): Don't add __ to __this. + +2009-09-30 Jason Merrill <jason@redhat.com> + * cp-tree.h (LANG_DECL_U2_CHECK): Check LANG_DECL_HAS_MIN. 2009-09-29 John Freeman <jfreeman08@gmail.com> 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; } |