2003-01-22 Mark Mitchell <mark@codesourcery.com>
+ PR c++/9298
+ * parser.c (cp_parser_consume_semicolon_at_end_of_statement): New
+ function.
+ (cp_parser_expression_statement): Use it.
+ (cp_parser_explicit_instantiation): Likewise.
+ * pt.c (do_decl_instantiation): Improve error handling logic.
+
+2003-01-22 Mark Mitchell <mark@codesourcery.com>
+
PR c++/9384
* parser.c (cp_parser_using_declaration): Issue error messages
about name resolution failures here.
(cp_parser *);
static void cp_parser_skip_to_end_of_statement
PARAMS ((cp_parser *));
+static void cp_parser_consume_semicolon_at_end_of_statement
+ (cp_parser *);
static void cp_parser_skip_to_end_of_block_or_statement
PARAMS ((cp_parser *));
static void cp_parser_skip_to_closing_brace
}
}
+/* This function is called at the end of a statement or declaration.
+ If the next token is a semicolon, it is consumed; otherwise, error
+ recovery is attempted. */
+
+static void
+cp_parser_consume_semicolon_at_end_of_statement (cp_parser *parser)
+{
+ /* Look for the trailing `;'. */
+ if (!cp_parser_require (parser, CPP_SEMICOLON, "`;'"))
+ {
+ /* If there is additional (erroneous) input, skip to the end of
+ the statement. */
+ cp_parser_skip_to_end_of_statement (parser);
+ /* If the next token is now a `;', consume it. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
+ cp_lexer_consume_token (parser->lexer);
+ }
+}
+
/* Skip tokens until we have consumed an entire block, or until we
have consumed a non-nested `;'. */
statement = NULL_TREE;
}
/* Consume the final `;'. */
- if (!cp_parser_require (parser, CPP_SEMICOLON, "`;'"))
- {
- /* If there is additional (erroneous) input, skip to the end of
- the statement. */
- cp_parser_skip_to_end_of_statement (parser);
- /* If the next token is now a `;', consume it. */
- if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
- cp_lexer_consume_token (parser->lexer);
- }
+ cp_parser_consume_semicolon_at_end_of_statement (parser);
return statement;
}
/* Trun access control back on. */
scope_chain->check_access = flag_access_control;
- /* Look for the trailing `;'. */
- cp_parser_require (parser, CPP_SEMICOLON, "`;'");
+ cp_parser_consume_semicolon_at_end_of_statement (parser);
}
/* Parse an explicit-specialization.
should handle VAR_DECLs as it currently handles
FUNCTION_DECLs. */
result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, 0);
- if (result && TREE_CODE (result) != VAR_DECL)
+ if (!result || TREE_CODE (result) != VAR_DECL)
{
- error ("no matching template for `%D' found", result);
+ error ("no matching template for `%D' found", decl);
return;
}
}