From: Jakub Jelinek Date: Tue, 29 Apr 2008 08:54:45 +0000 (+0200) Subject: re PR c++/35987 (ICE with invalid if-condition) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2be060fd3c04b05c22f3c75c1e32f5b1c7a0f43;p=gcc.git re PR c++/35987 (ICE with invalid if-condition) PR c++/35987 * typeck.c (cp_build_modify_expr) : Don't build COMPOUND_EXPR if the second argument would be error_mark_node. * g++.dg/other/error28.C: New test. From-SVN: r134786 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 368348a3d95..15aa14ca4f0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-04-29 Jakub Jelinek + + PR c++/35987 + * typeck.c (cp_build_modify_expr) : Don't build + COMPOUND_EXPR if the second argument would be error_mark_node. + 2008-04-28 Jason Merrill Liu Guanwei diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 42779562a88..bf264ad2cc7 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5945,10 +5945,11 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, lhs = build2 (TREE_CODE (lhs), TREE_TYPE (lhs), stabilize_reference (TREE_OPERAND (lhs, 0)), TREE_OPERAND (lhs, 1)); - return build2 (COMPOUND_EXPR, lhstype, - lhs, - cp_build_modify_expr (TREE_OPERAND (lhs, 0), - modifycode, rhs, complain)); + newrhs = cp_build_modify_expr (TREE_OPERAND (lhs, 0), + modifycode, rhs, complain); + if (newrhs == error_mark_node) + return error_mark_node; + return build2 (COMPOUND_EXPR, lhstype, lhs, newrhs); /* Handle (a, b) used as an "lvalue". */ case COMPOUND_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4ac8b14be5e..1154c105c9e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-04-29 Jakub Jelinek + + PR c++/35987 + * g++.dg/other/error28.C: New test. + 2008-04-28 Uros Bizjak PR target/36073 diff --git a/gcc/testsuite/g++.dg/other/error28.C b/gcc/testsuite/g++.dg/other/error28.C new file mode 100644 index 00000000000..5ac15b7de1e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error28.C @@ -0,0 +1,8 @@ +// PR c++/35987 +// { dg-do compile } + +void +foo (char *p) +{ + if (++p = true); // { dg-error "cannot convert" } +}