[C++ PATCH] Fix stmt expression error recovery (PR c++/35747)
Jakub Jelinek
jakub@redhat.com
Tue Apr 22 15:26:00 GMT 2008
Hi!
If a statement expression is errorneous (has error_mark_node TREE_TYPE),
finish_stmt_expr wouldn't pop stmt list pushed in begin_stmt_expr,
leading to a whole can of worms elsewhere.
Fixed thusly, regtested on x86_64-linux. Ok for trunk/4.3?
2008-04-22 Jakub Jelinek <jakub@redhat.com>
PR c++/35747
* semantics.c (finish_stmt_expr): Call pop_stmt_list even if the stmt
expression is errorneous.
* g++.dg/ext/stmtexpr13.C: New test.
--- gcc/cp/semantics.c.jj 2008-04-11 15:13:04.000000000 +0200
+++ gcc/cp/semantics.c 2008-04-22 15:09:42.000000000 +0200
@@ -1739,7 +1739,10 @@ finish_stmt_expr (tree stmt_expr, bool h
tree result;
if (error_operand_p (stmt_expr))
- return error_mark_node;
+ {
+ pop_stmt_list (stmt_expr);
+ return error_mark_node;
+ }
gcc_assert (TREE_CODE (stmt_expr) == STATEMENT_LIST);
--- gcc/testsuite/g++.dg/ext/stmtexpr13.C.jj 2008-04-22 15:14:19.000000000 +0200
+++ gcc/testsuite/g++.dg/ext/stmtexpr13.C 2008-04-22 15:13:39.000000000 +0200
@@ -0,0 +1,9 @@
+// PR c++/35747
+// { dg-do compile }
+// { dg-options "" }
+
+void
+foo ()
+{
+ ({ i; ({ i; }); 0; }); // { dg-error "was not declared" }
+}
Jakub
More information about the Gcc-patches
mailing list