From d7b5fa315012328dbd9b2fd6cb0e1c82942752c3 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 23 Apr 2008 00:06:58 +0200 Subject: [PATCH] re PR c++/35747 (ICE with undefined variable in statement expression) 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. From-SVN: r134567 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/stmtexpr13.C | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/stmtexpr13.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1ea37333236..71bb45ec65b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-04-22 Jakub Jelinek + + PR c++/35747 + * semantics.c (finish_stmt_expr): Call pop_stmt_list even if the stmt + expression is errorneous. + 2008-04-21 Jason Merrill PR c++/35325 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 12cf38750db..f31235b5625 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1739,7 +1739,10 @@ finish_stmt_expr (tree stmt_expr, bool has_no_scope) 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index af0d3207a67..cf689a4129f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-04-22 Jakub Jelinek + + PR c++/35747 + * g++.dg/ext/stmtexpr13.C: New test. + 2008-04-22 Ian Lance Taylor * gcc.c-torture/compile/20080419-1.c: New test. diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr13.C b/gcc/testsuite/g++.dg/ext/stmtexpr13.C new file mode 100644 index 00000000000..978da1584e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/stmtexpr13.C @@ -0,0 +1,9 @@ +// PR c++/35747 +// { dg-do compile } +// { dg-options "" } + +void +foo () +{ + ({ i; ({ i; }); 0; }); // { dg-error "was not declared" } +} -- 2.30.2