diff options
author | Volker Reichelt <reichelt@igpm.rwth-aachen.de> | 2006-08-03 02:49:07 +0000 |
---|---|---|
committer | Volker Reichelt <reichelt@gcc.gnu.org> | 2006-08-03 02:49:07 +0000 |
commit | c0dc47a866978c70a9c008882850dfdf059fd52d (patch) | |
tree | 94966bfa3bf0d1281f415061cff6db93401e69c4 /gcc/cp/parser.c | |
parent | 4a2f6dc05bb975426ff56d3656694684d292efbd (diff) | |
download | gcc-c0dc47a866978c70a9c008882850dfdf059fd52d.zip gcc-c0dc47a866978c70a9c008882850dfdf059fd52d.tar.gz gcc-c0dc47a866978c70a9c008882850dfdf059fd52d.tar.bz2 |
re PR c++/27508 (ICE on invalid destructor name)
PR c++/27508
* parser.c (cp_parser_unqualified_id): Check for invalid scopes
when parsing destructor names.
* g++.dg/parse/dtor9.C: New test.
* g++.dg/parse/dtor10.C: New test.
* g++.dg/other/error7.C: Adjust error-marker.
From-SVN: r115896
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c422401..aa29787 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3416,9 +3416,24 @@ cp_parser_unqualified_id (cp_parser* parser, object_scope = parser->object_scope; qualifying_scope = parser->qualifying_scope; + /* Check for invalid scopes. */ + if (scope == error_mark_node) + { + cp_parser_skip_to_end_of_statement (parser); + 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); + return error_mark_node; + } + gcc_assert (!scope || TYPE_P (scope)); + /* If the name is of the form "X::~X" it's OK. */ token = cp_lexer_peek_token (parser->lexer); - if (scope && TYPE_P (scope) + if (scope && token->type == CPP_NAME && (cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_OPEN_PAREN) @@ -3500,7 +3515,7 @@ cp_parser_unqualified_id (cp_parser* parser, destructor is the same as the name of the qualifying class. That allows us to keep parsing after running into ill-formed destructor names. */ - if (type_decl == error_mark_node && scope && TYPE_P (scope)) + if (type_decl == error_mark_node && scope) return build_nt (BIT_NOT_EXPR, scope); else if (type_decl == error_mark_node) return error_mark_node; |