diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-12-16 02:46:31 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-12-16 02:46:31 +0000 |
commit | 89f1a6eccc670a5d41d7aa2e8bdbe5793d662eda (patch) | |
tree | 666879933d74c747ef939964a372c4a7812082cf /gcc/cp/parser.c | |
parent | 040fc928031ee65c0eeed2ed20e024179d02d9cf (diff) | |
download | gcc-89f1a6eccc670a5d41d7aa2e8bdbe5793d662eda.zip gcc-89f1a6eccc670a5d41d7aa2e8bdbe5793d662eda.tar.gz gcc-89f1a6eccc670a5d41d7aa2e8bdbe5793d662eda.tar.bz2 |
re PR c++/10926 (ICE in build_delete when trying to declare template destructor)
PR c++/10926
* decl2.c (grokfield): Robustify.
PR c++/11116
* parser.c (cp_parser_throw_expression): Determine whether or not
an assignment-expression is present by doing one-token lookahead.
PR c++/10926
* g++.dg/template/error9.C: New test.
PR c++/11116
* g++.dg/template/error8.C: New test.
From-SVN: r74664
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index fd25aa2..14923b1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -12784,15 +12784,21 @@ static tree cp_parser_throw_expression (cp_parser* parser) { tree expression; + cp_token* token; cp_parser_require_keyword (parser, RID_THROW, "`throw'"); - /* We can't be sure if there is an assignment-expression or not. */ - cp_parser_parse_tentatively (parser); - /* Try it. */ - expression = cp_parser_assignment_expression (parser); - /* If it didn't work, this is just a rethrow. */ - if (!cp_parser_parse_definitely (parser)) + token = cp_lexer_peek_token (parser->lexer); + /* Figure out whether or not there is an assignment-expression + following the "throw" keyword. */ + if (token->type == CPP_COMMA + || token->type == CPP_SEMICOLON + || token->type == CPP_CLOSE_PAREN + || token->type == CPP_CLOSE_SQUARE + || token->type == CPP_CLOSE_BRACE + || token->type == CPP_COLON) expression = NULL_TREE; + else + expression = cp_parser_assignment_expression (parser); return build_throw (expression); } |