static void
cp_parser_objc_method_definition_list (cp_parser* parser)
{
- cp_token *token = cp_lexer_peek_token (parser->lexer);
-
- while (token->keyword != RID_AT_END && token->type != CPP_EOF)
+ for (;;)
{
- tree meth;
+ cp_token *token = cp_lexer_peek_token (parser->lexer);
- if (token->type == CPP_PLUS || token->type == CPP_MINUS)
+ if (token->keyword == RID_AT_END)
{
- cp_token *ptk;
- tree sig, attribute;
- bool is_class_method;
- if (token->type == CPP_PLUS)
- is_class_method = true;
- else
- is_class_method = false;
+ cp_lexer_consume_token (parser->lexer); /* Eat '@end'. */
+ break;
+ }
+ else if (token->type == CPP_EOF)
+ {
+ cp_parser_error (parser, "expected %<@end%>");
+ break;
+ }
+ else if (token->type == CPP_PLUS || token->type == CPP_MINUS)
+ {
+ bool is_class_method = token->type == CPP_PLUS;
+
push_deferring_access_checks (dk_deferred);
- sig = cp_parser_objc_method_signature (parser, &attribute);
+ tree attribute;
+ tree sig = cp_parser_objc_method_signature (parser, &attribute);
if (sig == error_mark_node)
+ cp_parser_skip_to_end_of_block_or_statement (parser);
+ else
{
- cp_parser_skip_to_end_of_block_or_statement (parser);
- token = cp_lexer_peek_token (parser->lexer);
- continue;
- }
- objc_start_method_definition (is_class_method, sig, attribute,
- NULL_TREE);
+ objc_start_method_definition (is_class_method, sig,
+ attribute, NULL_TREE);
- /* For historical reasons, we accept an optional semicolon. */
- if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
- cp_lexer_consume_token (parser->lexer);
+ /* For historical reasons, we accept an optional semicolon. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
+ cp_lexer_consume_token (parser->lexer);
- ptk = cp_lexer_peek_token (parser->lexer);
- if (!(ptk->type == CPP_PLUS || ptk->type == CPP_MINUS
- || ptk->type == CPP_EOF || ptk->keyword == RID_AT_END))
- {
perform_deferred_access_checks (tf_warning_or_error);
stop_deferring_access_checks ();
- meth = cp_parser_function_definition_after_declarator (parser,
- false);
+ tree meth
+ = cp_parser_function_definition_after_declarator (parser, false);
pop_deferring_access_checks ();
objc_finish_method_definition (meth);
}
else
/* Allow for interspersed non-ObjC++ code. */
cp_parser_objc_interstitial_code (parser);
-
- token = cp_lexer_peek_token (parser->lexer);
}
- if (token->type != CPP_EOF)
- cp_lexer_consume_token (parser->lexer); /* Eat '@end'. */
- else
- cp_parser_error (parser, "expected %<@end%>");
-
objc_finish_implementation ();
}