aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorSimon Martin <simartin@users.sourceforge.net>2006-12-31 16:09:07 +0000
committerSimon Martin <simartin@gcc.gnu.org>2006-12-31 16:09:07 +0000
commit7c2da05e604c27549afadf4df26c679aead5f414 (patch)
treeae5544b4685448570f3fe482042f9086491c090c /gcc/cp/parser.c
parent72ff1a96091ff6a1fb93e1c7087dc17f3c6c5d4b (diff)
downloadgcc-7c2da05e604c27549afadf4df26c679aead5f414.zip
gcc-7c2da05e604c27549afadf4df26c679aead5f414.tar.gz
gcc-7c2da05e604c27549afadf4df26c679aead5f414.tar.bz2
re PR c++/29731 (ICE with statement expression as template parameter)
2006-12-31 Simon Martin <simartin@users.sourceforge.net> PR c++/29731 * parser.c (cp_parser_primary_expression): Return error_mark_node when a statement-expression is found outside of a function body. From-SVN: r120299
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index ae2b4a0..82cb796 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -3024,13 +3024,20 @@ cp_parser_primary_expression (cp_parser *parser,
at class or namespace scope. */
if (!parser->in_function_body)
- error ("statement-expressions are allowed only inside functions");
- /* Start the statement-expression. */
- expr = begin_stmt_expr ();
- /* Parse the compound-statement. */
- cp_parser_compound_statement (parser, expr, false);
- /* Finish up. */
- expr = finish_stmt_expr (expr, false);
+ {
+ error ("statement-expressions are allowed only inside functions");
+ cp_parser_skip_to_end_of_block_or_statement (parser);
+ expr = error_mark_node;
+ }
+ else
+ {
+ /* Start the statement-expression. */
+ expr = begin_stmt_expr ();
+ /* Parse the compound-statement. */
+ cp_parser_compound_statement (parser, expr, false);
+ /* Finish up. */
+ expr = finish_stmt_expr (expr, false);
+ }
}
else
{