aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 5ec8b1b..f672b8d 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -9899,7 +9899,25 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
cp_lexer_consume_token (parser->lexer);
add_capture (lambda_expr,
/*id=*/this_identifier,
- /*initializer=*/finish_this_expr(),
+ /*initializer=*/finish_this_expr (),
+ /*by_reference_p=*/true,
+ explicit_init_p);
+ continue;
+ }
+
+ /* Possibly capture `*this'. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_MULT)
+ && cp_lexer_nth_token_is_keyword (parser->lexer, 2, RID_THIS))
+ {
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
+ if (cxx_dialect < cxx1z)
+ pedwarn (loc, 0, "%<*this%> capture only available with "
+ "-std=c++1z or -std=gnu++1z");
+ cp_lexer_consume_token (parser->lexer);
+ cp_lexer_consume_token (parser->lexer);
+ add_capture (lambda_expr,
+ /*id=*/this_identifier,
+ /*initializer=*/finish_this_expr (),
/*by_reference_p=*/false,
explicit_init_p);
continue;