aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2011-01-08 19:44:30 +0000
committerNicola Pero <nicola@gcc.gnu.org>2011-01-08 19:44:30 +0000
commit046608a3e0569946f4a499c59e02f45b057d7251 (patch)
tree7f721598e3310166b94d26cc0b888759037b4960 /gcc/cp/parser.c
parentf1f39033accfe89082fc2701d02bd65b57df0978 (diff)
downloadgcc-046608a3e0569946f4a499c59e02f45b057d7251.zip
gcc-046608a3e0569946f4a499c59e02f45b057d7251.tar.gz
gcc-046608a3e0569946f4a499c59e02f45b057d7251.tar.bz2
In gcc/: 2011-01-08 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/: 2011-01-08 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/47078 * c-parser.c (c_parser_objc_type_name): If the type is unknown, for error recovery purposes behave as if it was not specified so that the default type is usd. In gcc/testsuite/: 2011-01-08 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/47078 * objc.dg/invalid-method-2.m: New. * obj-c++.dg/invalid-method-2.mm: New. In gcc/cp/: 2011-01-08 Nicola Pero <nicola.pero@meta-innovation.com> PR objc/47078 * parser.c (cp_parser_objc_typename): If the type is unknown, for error recovery purposes behave as if it was not specified so that the default type is used. From-SVN: r168601
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 43e91b0..2f11f8e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -21915,7 +21915,25 @@ cp_parser_objc_typename (cp_parser* parser)
/* An ObjC type name may consist of just protocol qualifiers, in which
case the type shall default to 'id'. */
if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
- cp_type = cp_parser_type_id (parser);
+ {
+ cp_type = cp_parser_type_id (parser);
+
+ /* If the type could not be parsed, an error has already
+ been produced. For error recovery, behave as if it had
+ not been specified, which will use the default type
+ 'id'. */
+ if (cp_type == error_mark_node)
+ {
+ cp_type = NULL_TREE;
+ /* We need to skip to the closing parenthesis as
+ cp_parser_type_id() does not seem to do it for
+ us. */
+ cp_parser_skip_to_closing_parenthesis (parser,
+ /*recovering=*/true,
+ /*or_comma=*/false,
+ /*consume_paren=*/false);
+ }
+ }
cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
type_name = build_tree_list (proto_quals, cp_type);