diff options
author | Simon Martin <simartin@users.sourceforge.net> | 2007-05-25 20:26:36 +0000 |
---|---|---|
committer | Simon Martin <simartin@gcc.gnu.org> | 2007-05-25 20:26:36 +0000 |
commit | 1094da913be99ab5768f3a37bb955ae60f85006d (patch) | |
tree | 1e64bb39a5081cc53752f25e2be1fe856894fd75 /gcc | |
parent | eb89f88cb853ff9e2604c9414360a312a39263ab (diff) | |
download | gcc-1094da913be99ab5768f3a37bb955ae60f85006d.zip gcc-1094da913be99ab5768f3a37bb955ae60f85006d.tar.gz gcc-1094da913be99ab5768f3a37bb955ae60f85006d.tar.bz2 |
re PR c++/31745 (ICE on invalid use of namespace)
2007-05-25 Simon Martin <simartin@users.sourceforge.net>
Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/31745
* parser.c (cp_parser_skip_to_closing_brace): Return true if the next
token is a closing brace, false if there are no tokens left.
(cp_parser_namespace_alias_definition): Only consume the next token if
it is a closing brace.
* parser.c (cp_parser_class_specifier): Likewise.
Co-Authored-By: Lee Millward <lee.millward@gmail.com>
Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org>
From-SVN: r125070
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/parser.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/crash34.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/crash35.C | 7 |
5 files changed, 42 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 32dee7f..5b4d88c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2007-05-25 Simon Martin <simartin@users.sourceforge.net> + Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR c++/31745 + * parser.c (cp_parser_skip_to_closing_brace): Return true if the next + token is a closing brace, false if there are no tokens left. + (cp_parser_namespace_alias_definition): Only consume the next token if + it is a closing brace. + + * parser.c (cp_parser_class_specifier): Likewise. + 2007-05-25 H.J. Lu <hongjiu.lu@intel.com> * semantics.c (finish_member_declaration): Fix a typo in the diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 4599aca..e7b90b2 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1999,7 +1999,7 @@ static void cp_parser_consume_semicolon_at_end_of_statement (cp_parser *); static void cp_parser_skip_to_end_of_block_or_statement (cp_parser *); -static void cp_parser_skip_to_closing_brace +static bool cp_parser_skip_to_closing_brace (cp_parser *); static void cp_parser_skip_to_end_of_template_parameter_list (cp_parser *); @@ -2599,9 +2599,10 @@ cp_parser_skip_to_end_of_block_or_statement (cp_parser* parser) } /* Skip tokens until a non-nested closing curly brace is the next - token. */ + token, or there are no more tokens. Return true in the first case, + false otherwise. */ -static void +static bool cp_parser_skip_to_closing_brace (cp_parser *parser) { unsigned nesting_depth = 0; @@ -2615,13 +2616,13 @@ cp_parser_skip_to_closing_brace (cp_parser *parser) case CPP_EOF: case CPP_PRAGMA_EOL: /* If we've run out of tokens, stop. */ - return; + return false; case CPP_CLOSE_BRACE: /* If the next token is a non-nested `}', then we have reached the end of the current block. */ if (nesting_depth-- == 0) - return; + return true; break; case CPP_OPEN_BRACE: @@ -11295,8 +11296,8 @@ cp_parser_namespace_alias_definition (cp_parser* parser) error ("%<namespace%> definition is not allowed here"); /* Skip the definition. */ cp_lexer_consume_token (parser->lexer); - cp_parser_skip_to_closing_brace (parser); - cp_lexer_consume_token (parser->lexer); + if (cp_parser_skip_to_closing_brace (parser)) + cp_lexer_consume_token (parser->lexer); return; } cp_parser_require (parser, CPP_EQ, "`='"); @@ -13818,11 +13819,10 @@ cp_parser_class_specifier (cp_parser* parser) entire class body. */ if (!xref_basetypes (type, bases)) { - cp_parser_skip_to_closing_brace (parser); - /* Consuming the closing brace yields better error messages later on. */ - cp_lexer_consume_token (parser->lexer); + if (cp_parser_skip_to_closing_brace (parser)) + cp_lexer_consume_token (parser->lexer); pop_deferring_access_checks (); return error_mark_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ed41a7f..0da350c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-05-25 Simon Martin <simartin@users.sourceforge.net> + Lee Millward <lee.millward@gmail.com> + + PR c++/31745 + * g++.dg/parse/crash34.C: New test. + + * g++.dg/parse/crash35.C: New test. + 2007-05-25 H.J. Lu <hongjiu.lu@intel.com> * gcc.target/i386/sse2-check.h: New. diff --git a/gcc/testsuite/g++.dg/parse/crash34.C b/gcc/testsuite/g++.dg/parse/crash34.C new file mode 100644 index 0000000..e2517a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash34.C @@ -0,0 +1,6 @@ +/* PR c++/31745 */ +/* { dg-do "compile" } */ + +void foo() +{ + namespace N { /* { dg-error "is not allowed|at end of input" } */ diff --git a/gcc/testsuite/g++.dg/parse/crash35.C b/gcc/testsuite/g++.dg/parse/crash35.C new file mode 100644 index 0000000..a0448af --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash35.C @@ -0,0 +1,7 @@ +/* This used to ICE. */ +/* { dg-do "compile" } */ + +struct a {}; + +class foo : public a, a +{ /* { dg-error "duplicate base type|at end of input" } */ |