diff options
author | Jason Merrill <jason@redhat.com> | 2011-03-10 10:21:00 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-03-10 10:21:00 -0500 |
commit | 4999d9b0135878f24eae78f33142b4929274dd54 (patch) | |
tree | be33bedd89aa2d35e4d9b0c5180f1296a13dc3b6 /gcc/cp/parser.c | |
parent | 392426866e8caa70e52ad562423c13191a5667a3 (diff) | |
download | gcc-4999d9b0135878f24eae78f33142b4929274dd54.zip gcc-4999d9b0135878f24eae78f33142b4929274dd54.tar.gz gcc-4999d9b0135878f24eae78f33142b4929274dd54.tar.bz2 |
re PR c++/47198 ([C++0x] ICE: tree check: expected var_decl or function_decl, have template_decl in check_bases_and_members, at cp/class.c:4654 on invalid code)
PR c++/47198
* parser.c (cp_parser_single_declaration): Just return if
cp_parser_parse_and_diagnose_invalid_type_name complained.
From-SVN: r170847
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 510fcb1..7e9b286 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -20102,8 +20102,15 @@ cp_parser_single_declaration (cp_parser* parser, } /* Complain about missing 'typename' or other invalid type names. */ - if (!decl_specifiers.any_type_specifiers_p) - cp_parser_parse_and_diagnose_invalid_type_name (parser); + if (!decl_specifiers.any_type_specifiers_p + && cp_parser_parse_and_diagnose_invalid_type_name (parser)) + { + /* cp_parser_parse_and_diagnose_invalid_type_name calls + cp_parser_skip_to_end_of_block_or_statement, so don't try to parse + the rest of this declaration. */ + decl = error_mark_node; + goto out; + } /* If it's not a template class, try for a template function. If the next token is a `;', then this declaration does not declare @@ -20137,6 +20144,13 @@ cp_parser_single_declaration (cp_parser* parser, } } + /* Look for a trailing `;' after the declaration. */ + if (!function_definition_p + && (decl == error_mark_node + || !cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON))) + cp_parser_skip_to_end_of_block_or_statement (parser); + + out: pop_deferring_access_checks (); /* Clear any current qualification; whatever comes next is the start @@ -20144,11 +20158,6 @@ cp_parser_single_declaration (cp_parser* parser, parser->scope = NULL_TREE; parser->qualifying_scope = NULL_TREE; parser->object_scope = NULL_TREE; - /* Look for a trailing `;' after the declaration. */ - if (!function_definition_p - && (decl == error_mark_node - || !cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON))) - cp_parser_skip_to_end_of_block_or_statement (parser); return decl; } |