aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-03-25 14:00:37 -0400
committerJason Merrill <jason@gcc.gnu.org>2014-03-25 14:00:37 -0400
commit1cbba79d074af647f641e9b684b8bba242421241 (patch)
tree77953a194d931e793e575b2f0a0d3a09e0fe9fb2 /gcc/cp
parent45156f1474c97ecc7147951b36714fe4655676af (diff)
downloadgcc-1cbba79d074af647f641e9b684b8bba242421241.zip
gcc-1cbba79d074af647f641e9b684b8bba242421241.tar.gz
gcc-1cbba79d074af647f641e9b684b8bba242421241.tar.bz2
re PR c++/60375 ([c++11] ICE with invalid use of lambda)
PR c++/60375 * parser.c (cp_parser_lambda_expression): Don't parse the body of a lambda in unevaluated context. From-SVN: r208817
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/parser.c16
2 files changed, 15 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 47c9890..23a2c8f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2014-03-25 Jason Merrill <jason@redhat.com>
+ PR c++/60375
+ * parser.c (cp_parser_lambda_expression): Don't parse the body of
+ a lambda in unevaluated context.
+
PR c++/60628
* decl.c (create_array_type_for_decl): Complain about array of auto.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4ca08a1..2e117a5 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -8718,14 +8718,17 @@ cp_parser_lambda_expression (cp_parser* parser)
{
tree lambda_expr = build_lambda_expr ();
tree type;
- bool ok;
+ bool ok = true;
LAMBDA_EXPR_LOCATION (lambda_expr)
= cp_lexer_peek_token (parser->lexer)->location;
if (cp_unevaluated_operand)
- error_at (LAMBDA_EXPR_LOCATION (lambda_expr),
- "lambda-expression in unevaluated context");
+ {
+ error_at (LAMBDA_EXPR_LOCATION (lambda_expr),
+ "lambda-expression in unevaluated context");
+ ok = false;
+ }
/* We may be in the middle of deferred access check. Disable
it now. */
@@ -8770,12 +8773,15 @@ cp_parser_lambda_expression (cp_parser* parser)
/* By virtue of defining a local class, a lambda expression has access to
the private variables of enclosing classes. */
- ok = cp_parser_lambda_declarator_opt (parser, lambda_expr);
+ ok &= cp_parser_lambda_declarator_opt (parser, lambda_expr);
if (ok)
cp_parser_lambda_body (parser, lambda_expr);
else if (cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE))
- cp_parser_skip_to_end_of_block_or_statement (parser);
+ {
+ if (cp_parser_skip_to_closing_brace (parser))
+ cp_lexer_consume_token (parser->lexer);
+ }
/* The capture list was built up in reverse order; fix that now. */
LAMBDA_EXPR_CAPTURE_LIST (lambda_expr)