+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>
* cp-tree.h (TYPE_NAMESPACE_SCOPE_P, TYPE_FUNCTION_SCOPE_P):
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
{
+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>
PR middle-end/30338
--- /dev/null
+/* 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" } */