re PR c++/9851 (confusing error message when using '.', not '->')

PR c++/9851
	* parser.c (cp_parser_pseudo_destructor_name): Check for errors on
	the type name and look ahead for ::~, and bail out early with a
	better error message if the parse is going to fail.

From-SVN: r77758
This commit is contained in:
Ian Lance Taylor 2004-02-13 16:11:39 +00:00 committed by Ian Lance Taylor
parent faeb9bb6ee
commit d6e57462de
2 changed files with 23 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2004-02-13 Ian Lance Taylor <ian@wasabisystems.com>
PR c++/9851
* parser.c (cp_parser_pseudo_destructor_name): Check for errors on
the type name and look ahead for ::~, and bail out early with a
better error message if the parse is going to fail.
2004-02-12 Mark Mitchell <mark@codesourcery.com>
* call.c (conversion_kind): New type.

View File

@ -4187,7 +4187,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
If either of the first two productions is used, sets *SCOPE to the
TYPE specified before the final `::'. Otherwise, *SCOPE is set to
NULL_TREE. *TYPE is set to the TYPE_DECL for the final type-name,
or ERROR_MARK_NODE if no type-name is present. */
or ERROR_MARK_NODE if the parse fails. */
static void
cp_parser_pseudo_destructor_name (cp_parser* parser,
@ -4227,6 +4227,21 @@ cp_parser_pseudo_destructor_name (cp_parser* parser,
{
/* Look for the type-name. */
*scope = TREE_TYPE (cp_parser_type_name (parser));
/* If we didn't get an aggregate type, or we don't have ::~,
then something has gone wrong. Since the only caller of this
function is looking for something after `.' or `->' after a
scalar type, most likely the program is trying to get a
member of a non-aggregate type. */
if (*scope == error_mark_node
|| cp_lexer_next_token_is_not (parser->lexer, CPP_SCOPE)
|| cp_lexer_peek_nth_token (parser->lexer, 2)->type != CPP_COMPL)
{
cp_parser_error (parser, "request for member of non-aggregate type");
*type = error_mark_node;
return;
}
/* Look for the `::' token. */
cp_parser_require (parser, CPP_SCOPE, "`::'");
}