aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2018-08-21 18:37:23 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2018-08-21 18:37:23 +0000
commit774fb6c4eb205eaf9d3b6667e7de9c90cc1784ad (patch)
tree1eda2ec33c05aeb27bb7e881205a0ff36e5efab1 /gcc/cp/parser.c
parent55082d81a0cb409d2c1a54889bbed72b369c4da8 (diff)
downloadgcc-774fb6c4eb205eaf9d3b6667e7de9c90cc1784ad.zip
gcc-774fb6c4eb205eaf9d3b6667e7de9c90cc1784ad.tar.gz
gcc-774fb6c4eb205eaf9d3b6667e7de9c90cc1784ad.tar.bz2
re PR c++/86499 (lambda-expressions with capture-default are allowed at namespace scope)
PR c++/86499 * parser.c (cp_parser_lambda_introducer): Give error if a non-local lambda has a capture-default. * g++.dg/cpp0x/lambda/lambda-non-local.C: New test. * g++.dg/cpp0x/lambda/lambda-this10.C: Adjust dg-error. From-SVN: r263749
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index aa5286b..49d476b 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10285,6 +10285,9 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
{
cp_lexer_consume_token (parser->lexer);
first = false;
+
+ if (!(at_function_scope_p () || parsing_nsdmi ()))
+ error ("non-local lambda expression cannot have a capture-default");
}
while (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_SQUARE))