===================================================================
@@ -0,0 +1 @@
+@interface /* { dg-error "expected identifier" } */
In gcc/cp:
2010-10-05 Nicola Pero <nicola.pero@meta-innovation.com>
PR objc++/31125
* parser.c (cp_parser_objc_class_interface): If no identifier
follows an @interface token, stop parsing the interface after
printing an error.
(cp_parser_objc_class_implementation): If no identifier follows an
@implementation token, stop parsing the implementation after
printing an error.
===================================================================
@@ -21932,6 +21976,15 @@ cp_parser_objc_class_interface (cp_parser* parser,
cp_lexer_consume_token (parser->lexer); /* Eat '@interface'. */
name = cp_parser_identifier (parser);
+ if (name == error_mark_node)
+ {
+ /* It's hard to recover because even if valid @interface stuff
+ is to follow, we can't compile it (or validate it) if we
+ don't even know which class it refers to. Let's assume this
+ was a stray '@interface' token in the stream and skip it.
+ */
+ return;
+ }
cp_parser_objc_superclass_or_category (parser, &super, &categ);
protos = cp_parser_objc_protocol_refs_opt (parser);
@@ -21958,6 +22011,16 @@ cp_parser_objc_class_implementation (cp_parser* pa
cp_lexer_consume_token (parser->lexer); /* Eat '@implementation'. */
name = cp_parser_identifier (parser);
+ if (name == error_mark_node)
+ {
+ /* It's hard to recover because even if valid @implementation
+ stuff is to follow, we can't compile it (or validate it) if
+ we don't even know which class it refers to. Let's assume
+ this was a stray '@implementation' token in the stream and
+ skip it.
+ */
+ return;
+ }
cp_parser_objc_superclass_or_category (parser, &super, &categ);
/* We have either a class or a category on our hands. */