Commit 7c2da05e by Simon Martin Committed by Simon Martin

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
parent 72ff1a96
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.
2006-12-28 Kazu Hirata <kazu@codesourcery.com> 2006-12-28 Kazu Hirata <kazu@codesourcery.com>
* cp-tree.h (TYPE_NAMESPACE_SCOPE_P, TYPE_FUNCTION_SCOPE_P): * cp-tree.h (TYPE_NAMESPACE_SCOPE_P, TYPE_FUNCTION_SCOPE_P):
......
...@@ -3024,13 +3024,20 @@ cp_parser_primary_expression (cp_parser *parser, ...@@ -3024,13 +3024,20 @@ cp_parser_primary_expression (cp_parser *parser,
at class or namespace scope. */ at class or namespace scope. */
if (!parser->in_function_body) if (!parser->in_function_body)
error ("statement-expressions are allowed only inside functions"); {
/* Start the statement-expression. */ error ("statement-expressions are allowed only inside functions");
expr = begin_stmt_expr (); cp_parser_skip_to_end_of_block_or_statement (parser);
/* Parse the compound-statement. */ expr = error_mark_node;
cp_parser_compound_statement (parser, expr, false); }
/* Finish up. */ else
expr = finish_stmt_expr (expr, false); {
/* 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 else
{ {
......
2006-12-31 Simon Martin <simartin@users.sourceforge.net>
PR c++/29731
* g++.dg/parse/template22.C: New test.
2006-12-31 Richard Guenther <rguenther@suse.de> 2006-12-31 Richard Guenther <rguenther@suse.de>
PR middle-end/30338 PR middle-end/30338
/* PR c++/29731. This used to ICE in uses_template_parms. */
template<int> struct A {};
A<({})> a; /* { dg-error "forbids braced-groups within expressions|statement-expressions|template argument 1 is invalid|invalid type" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment