diff options
author | Iain Sandoe <iain@codesourcery.com> | 2014-12-31 13:58:16 +0000 |
---|---|---|
committer | Iain Sandoe <iains@gcc.gnu.org> | 2014-12-31 13:58:16 +0000 |
commit | e8ef82d74f40e216b3a1c9707a79a3bd0b6c953d (patch) | |
tree | 89e697fd28a192c9f4e58f50181106401914964d /gcc/cp | |
parent | 0d391d25ae4899249202ec9d68a8c576165d5ba2 (diff) | |
download | gcc-e8ef82d74f40e216b3a1c9707a79a3bd0b6c953d.zip gcc-e8ef82d74f40e216b3a1c9707a79a3bd0b6c953d.tar.gz gcc-e8ef82d74f40e216b3a1c9707a79a3bd0b6c953d.tar.bz2 |
Allow Objective-c++ to recognise lambdas.
gcc/cp:
* parser.c (cp_parser_primary_expression): If parsing an
objective-c++ message expression fails, see if a lambda is present.
(cp_parser_objc_message_receiver): Don't assume that, if a message
receiver expression fails, it is a hard error.
gcc/testsuite:
* obj-c++.dg/lambda-0.mm New.
* obj-c++.dg/lambda-1.mm New.
* obj-c++.dg/syntax-error-6.mm Adjust for revised error messages.
From-SVN: r219125
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 21 |
2 files changed, 24 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bd5dd49..a6ce50b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2014-12-31 Iain Sandoe <iain@codesourcery.com> + + * parser.c (cp_parser_primary_expression): If parsing an + objective-c++ message expression fails, see if a lambda is present. + (cp_parser_objc_message_receiver): Don't assume that, if a message + receiver expression fails, it is a hard error. + 2014-12-25 Jason Merrill <jason@redhat.com> * pt.c (check_default_tmpl_args): Uses the parameter source diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 2af1576..68940aa 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4442,10 +4442,17 @@ cp_parser_primary_expression (cp_parser *parser, } case CPP_OPEN_SQUARE: - if (c_dialect_objc ()) - /* We have an Objective-C++ message. */ - return cp_parser_objc_expression (parser); { + if (c_dialect_objc ()) + { + /* We might have an Objective-C++ message. */ + cp_parser_parse_tentatively (parser); + tree msg = cp_parser_objc_message_expression (parser); + /* If that works out, we're done ... */ + if (cp_parser_parse_definitely (parser)) + return msg; + /* ... else, fall though to see if it's a lambda. */ + } tree lam = cp_parser_lambda_expression (parser); /* Don't warn about a failed tentative parse. */ if (cp_parser_error_occurred (parser)) @@ -25657,14 +25664,20 @@ cp_parser_objc_message_receiver (cp_parser* parser) cp_parser_parse_tentatively (parser); rcv = cp_parser_expression (parser); + /* If that worked out, fine. */ if (cp_parser_parse_definitely (parser)) return rcv; + cp_parser_parse_tentatively (parser); rcv = cp_parser_simple_type_specifier (parser, /*decl_specs=*/NULL, CP_PARSER_FLAGS_NONE); - return objc_get_class_reference (rcv); + if (cp_parser_parse_definitely (parser)) + return objc_get_class_reference (rcv); + + cp_parser_error (parser, "objective-c++ message receiver expected"); + return error_mark_node; } /* Parse the arguments and selectors comprising an Objective-C message. |