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 368348a..15aa14c 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 4277956..bf264ad 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 4ac8b14..1154c10 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" }
+}