aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>2006-08-17 09:07:39 +0000
committerVolker Reichelt <reichelt@gcc.gnu.org>2006-08-17 09:07:39 +0000
commit04499540e222f831f1ebc76c726701779001b8ee (patch)
tree0c190760dbae3e7281868aa5ab64276418b10d53 /gcc/cp/parser.c
parent3f1e3e7010cf18ef218f107015b8f66fc75ed4d9 (diff)
downloadgcc-04499540e222f831f1ebc76c726701779001b8ee.zip
gcc-04499540e222f831f1ebc76c726701779001b8ee.tar.gz
gcc-04499540e222f831f1ebc76c726701779001b8ee.tar.bz2
re PR c++/28606 (Destructor accepted as return-type of constructor)
PR c++/28606 * parser.c (cp_parser_diagnose_invalid_type_name): Handle BIT_NOT_EXPR. Fix formatting. (cp_parser_parse_and_diagnose_invalid_type_name): Tighten condition for valid type-names. (cp_parser_unqualified_id): Fix error handling for destructors. * g++.dg/parse/dtor11.C: New test. From-SVN: r116217
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7bfa866..78e6eb6 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -2093,8 +2093,9 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id)
/* If the lookup found a template-name, it means that the user forgot
to specify an argument list. Emit a useful error message. */
if (TREE_CODE (decl) == TEMPLATE_DECL)
- error ("invalid use of template-name %qE without an argument list",
- decl);
+ error ("invalid use of template-name %qE without an argument list", decl);
+ else if (TREE_CODE (id) == BIT_NOT_EXPR)
+ error ("invalid use of destructor %qD as a type", id);
else if (!parser->scope)
{
/* Issue an error message. */
@@ -2187,8 +2188,7 @@ cp_parser_parse_and_diagnose_invalid_type_name (cp_parser *parser)
cp_parser_abort_tentative_parse (parser);
return false;
}
- if (!cp_parser_parse_definitely (parser)
- || TREE_CODE (id) != IDENTIFIER_NODE)
+ if (!cp_parser_parse_definitely (parser) || TREE_CODE (id) == TYPE_DECL)
return false;
/* Emit a diagnostic for the invalid type. */
@@ -3407,14 +3407,17 @@ cp_parser_unqualified_id (cp_parser* parser,
/* Check for invalid scopes. */
if (scope == error_mark_node)
{
- cp_parser_skip_to_end_of_statement (parser);
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ cp_lexer_consume_token (parser->lexer);
return error_mark_node;
}
if (scope && TREE_CODE (scope) == NAMESPACE_DECL)
{
if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
error ("scope %qT before %<~%> is not a class-name", scope);
- cp_parser_skip_to_end_of_statement (parser);
+ cp_parser_simulate_error (parser);
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ cp_lexer_consume_token (parser->lexer);
return error_mark_node;
}
gcc_assert (!scope || TYPE_P (scope));
@@ -3514,6 +3517,7 @@ cp_parser_unqualified_id (cp_parser* parser,
if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
error ("declaration of %<~%T%> as member of %qT",
type_decl, scope);
+ cp_parser_simulate_error (parser);
return error_mark_node;
}