From 806010b9faf8e87d4bbdb01f0912801796f30708 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 17 Jun 2011 16:07:45 -0400 Subject: [PATCH] parser.c (cp_parser_lambda_expression): Clear LAMBDA_EXPR_THIS_CAPTURE after parsing. * parser.c (cp_parser_lambda_expression): Clear LAMBDA_EXPR_THIS_CAPTURE after parsing. * pt.c (tsubst_copy_and_build): Make sure it isn't set. From-SVN: r175156 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/cp-tree.h | 3 ++- gcc/cp/parser.c | 3 +++ gcc/cp/pt.c | 3 +-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e90d12da42c..baa4899743c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-06-17 Jason Merrill + * parser.c (cp_parser_lambda_expression): Clear + LAMBDA_EXPR_THIS_CAPTURE after parsing. + * pt.c (tsubst_copy_and_build): Make sure it isn't set. + * cp-tree.h (struct tree_lambda_expr): Change common to typed. Move non-pointers to end of struct. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ee303fec883..cf1c5927cb0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -625,7 +625,8 @@ enum cp_lambda_default_capture_mode_type { #define LAMBDA_EXPR_CAPTURE_LIST(NODE) \ (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->capture_list) -/* The node in the capture-list that holds the 'this' capture. */ +/* During parsing of the lambda, the node in the capture-list that holds + the 'this' capture. */ #define LAMBDA_EXPR_THIS_CAPTURE(NODE) \ (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->this_capture) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5ea04b56cb5..a9cedcf38ab 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7430,6 +7430,9 @@ cp_parser_lambda_expression (cp_parser* parser) pop_deferring_access_checks (); + /* This field is only used during parsing of the lambda. */ + LAMBDA_EXPR_THIS_CAPTURE (lambda_expr) = NULL_TREE; + if (ok) return build_lambda_object (lambda_expr); else diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 308aff7bc48..ca4f955cc12 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13498,10 +13498,9 @@ tsubst_copy_and_build (tree t, = (LAMBDA_EXPR_DISCRIMINATOR (t)); LAMBDA_EXPR_CAPTURE_LIST (r) = RECUR (LAMBDA_EXPR_CAPTURE_LIST (t)); - LAMBDA_EXPR_THIS_CAPTURE (r) - = RECUR (LAMBDA_EXPR_THIS_CAPTURE (t)); LAMBDA_EXPR_EXTRA_SCOPE (r) = RECUR (LAMBDA_EXPR_EXTRA_SCOPE (t)); + gcc_assert (LAMBDA_EXPR_THIS_CAPTURE (t) == NULL_TREE); /* Do this again now that LAMBDA_EXPR_EXTRA_SCOPE is set. */ determine_visibility (TYPE_NAME (type)); -- 2.30.2