From 4100761fc7fc03910f8cb3193f24c6b3632e4065 Mon Sep 17 00:00:00 2001 From: pinskia Date: Fri, 16 Feb 2007 01:23:35 +0000 Subject: [PATCH] 2007-02-15 Andrew Pinski PR C++/30158 * semantics.c (finish_stmt_expr_expr): Set TREE_TYPE of the statement expression if we had an error mark node. 2007-02-15 Andrew Pinski PR C++/30158 * g++.dg/ext/stmtexpr10.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122028 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 7 ++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/stmtexpr10.C | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/stmtexpr10.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 16df0f7..6e7f84f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-02-15 Andrew Pinski + + PR C++/30158 + * semantics.c (finish_stmt_expr_expr): Set TREE_TYPE of the + statement expression if we had an error mark node. + 2007-02-15 Sandra Loosemore Brooks Moses Lee Millward diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3df045e..c4cdd95 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1631,7 +1631,12 @@ tree finish_stmt_expr_expr (tree expr, tree stmt_expr) { if (error_operand_p (expr)) - return error_mark_node; + { + /* The type of the statement-expression is the type of the last + expression. */ + TREE_TYPE (stmt_expr) = error_mark_node; + return error_mark_node; + } /* If the last statement does not have "void" type, then the value of the last statement is the value of the entire expression. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 20c5591..c0fc66a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2007-02-15 Andrew Pinski + PR C++/30158 + * g++.dg/ext/stmtexpr10.C: New testcase. + +2007-02-15 Andrew Pinski + PR middle-end/30729 * gcc.dg/Wunused-value-2.c: New testcase. diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr10.C b/gcc/testsuite/g++.dg/ext/stmtexpr10.C new file mode 100644 index 0000000..f7c5f8f --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/stmtexpr10.C @@ -0,0 +1,16 @@ +/* { dg-do compile } " */ +/* { dg-options "" } */ + +void foo(int i) +{ + (i ? 1 : 2) = ({ X; }); /* { dg-error "" } */ +} + +struct A +{ + ~A (); + void foo() + { + delete this = ({ X; }); /* { dg-error "" } */ + } +}; -- 2.7.4