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
+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
2007-05-25 H.J. Lu <hongjiu.lu@intel.com>
* semantics.c (finish_member_declaration): Fix a typo in the
(cp_parser *);
static void cp_parser_skip_to_end_of_block_or_statement
(cp_parser *);
(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 *);
(cp_parser *);
static void cp_parser_skip_to_end_of_template_parameter_list
(cp_parser *);
}
/* Skip tokens until a non-nested closing curly brace is the next
}
/* Skip tokens until a non-nested closing curly brace is the next
+ token, or there are no more tokens. Return true in the first case,
+ false otherwise. */
cp_parser_skip_to_closing_brace (cp_parser *parser)
{
unsigned nesting_depth = 0;
cp_parser_skip_to_closing_brace (cp_parser *parser)
{
unsigned nesting_depth = 0;
case CPP_EOF:
case CPP_PRAGMA_EOL:
/* If we've run out of tokens, stop. */
case CPP_EOF:
case CPP_PRAGMA_EOL:
/* If we've run out of tokens, stop. */
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)
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)
break;
case CPP_OPEN_BRACE:
break;
case CPP_OPEN_BRACE:
error ("%<namespace%> definition is not allowed here");
/* Skip the definition. */
cp_lexer_consume_token (parser->lexer);
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, "`='");
return;
}
cp_parser_require (parser, CPP_EQ, "`='");
entire class body. */
if (!xref_basetypes (type, bases))
{
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. */
/* 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;
}
pop_deferring_access_checks ();
return error_mark_node;
}
+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.
2007-05-25 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/sse2-check.h: New.
--- /dev/null
+/* PR c++/31745 */
+/* { dg-do "compile" } */
+
+void foo()
+{
+ namespace N { /* { dg-error "is not allowed|at end of input" } */
--- /dev/null
+/* This used to ICE. */
+/* { dg-do "compile" } */
+
+struct a {};
+
+class foo : public a, a
+{ /* { dg-error "duplicate base type|at end of input" } */