Hi,
here I'm just handling error_mark_nodes after the error messages: I
think the robustification is sensible because begin_class_definition can
certainly return error_mark_node in general and sooner or later Volker
will find testcases producing more ;)
However, from the user point of view, it could be argued that typing the
below isn't *really* normal when coding with lambdas, in principle the
error messages preceding the ICE could be completely different and still
make sense...
Tested x86_64-linux.
Thanks,
Paolo.
/////////////////////
/cp
2011-12-08 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51464
* semantics.c (begin_lambda_type): Check begin_class_definition return
value for error_mark_node.
* parser.c (cp_parser_lambda_expression): Check begin_lambda_type
return value for error_mark_node.
/testsuite
2011-12-08 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51464
* g++.dg/cpp0x/lambda/lambda-ice6.C: New.
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice6.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice6.C (revision 0)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice6.C (revision 0)
@@ -0,0 +1,4 @@
+// PR c++/51464
+// { dg-options "-std=c++0x" }
+
+template<int = sizeof([])> struct A {}; // { dg-error "lambda" }
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 182106)
+++ cp/semantics.c (working copy)
@@ -8603,6 +8603,8 @@ begin_lambda_type (tree lambda)
/* Start the class. */
type = begin_class_definition (type, /*attributes=*/NULL_TREE);
+ if (type == error_mark_node)
+ return error_mark_node;
/* Cross-reference the expression and the type. */
LAMBDA_EXPR_CLOSURE (lambda) = type;
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 182106)
+++ cp/parser.c (working copy)
@@ -8033,6 +8033,8 @@ cp_parser_lambda_expression (cp_parser* parser)
cp_parser_lambda_introducer (parser, lambda_expr);
type = begin_lambda_type (lambda_expr);
+ if (type == error_mark_node)
+ return error_mark_node;
record_lambda_scope (lambda_expr);