re PR c++/35987 (ICE with invalid if-condition)
authorJakub Jelinek <jakub@redhat.com>
Tue, 29 Apr 2008 08:54:45 +0000 (10:54 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 29 Apr 2008 08:54:45 +0000 (10:54 +0200)
PR c++/35987
* typeck.c (cp_build_modify_expr) <case PREINCREMENT_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

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/error28.C [new file with mode: 0644]

index 368348a3d95ae8c98cacf72c0603b05d05eb13df..15aa14ca4f057ca8cc536b8e5df8b6fea4d6cacd 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35987
+       * typeck.c (cp_build_modify_expr) <case PREINCREMENT_EXPR>: Don't build
+       COMPOUND_EXPR if the second argument would be error_mark_node.
+
 2008-04-28  Jason Merrill  <jason@redhat.com>
            Liu Guanwei <liu_gw@163.com>
 
index 42779562a88d2b379398462d2749af655bad55fd..bf264ad2cc731f448fd8e784d3dab022e9619677 100644 (file)
@@ -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:
index 4ac8b14be5e32ffdb6957ea59051d458fb21ba11..1154c105c9e68db3e024e980198764bdd446c1f5 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35987
+       * g++.dg/other/error28.C: New test.
+
 2008-04-28  Uros Bizjak  <ubizjak@gmail.com>
 
        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 (file)
index 0000000..5ac15b7
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/35987
+// { dg-do compile }
+
+void
+foo (char *p)
+{
+  if (++p = true);     // { dg-error "cannot convert" }
+}