+2018-08-21 Marek Polacek <polacek@redhat.com>
+
+ PR c++/86499
+ * parser.c (cp_parser_lambda_introducer): Give error if a non-local
+ lambda has a capture-default.
+
2018-08-21 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (check_static_variable_definition): Change to return void.
{
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))
* g++.dg/cpp0x/Wnarrowing12.C: New test.
* g++.dg/cpp0x/rv-cast5.C: Add static_cast.
+ PR c++/86499
+ * g++.dg/cpp0x/lambda/lambda-non-local.C: New test.
+ * g++.dg/cpp0x/lambda/lambda-this10.C: Adjust dg-error.
+
2018-08-21 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/expr_func7.adb, gnat.dg/expr_func7.ads: New testcase.
--- /dev/null
+// PR c++/86499
+// { dg-do compile { target c++11 } }
+
+auto l1 = [=]{}; // { dg-error "non-local lambda expression cannot have a capture-default" }
+auto l2 = [&]{}; // { dg-error "non-local lambda expression cannot have a capture-default" }
+
+namespace {
+ auto l3 = [=]{}; // { dg-error "non-local lambda expression cannot have a capture-default" }
+ auto l4 = [&]{}; // { dg-error "non-local lambda expression cannot have a capture-default" }
+}
// PR c++/54383
// { dg-do compile { target c++11 } }
-auto foo = [&](int a) { return a > this->b; }; // { dg-error "this" }
+auto foo = [&](int a) { return a > this->b; }; // { dg-error "non-local|this" }