summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-03 09:08:00 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-03 09:08:00 +0000
commit76008ac42aa83a8051d9cf9d9e2106099aec90df (patch)
tree2278f06f550aeb7aeabbae2ccf061eabc975882e
parentf83924bb910b9eb3c5c313de0cfdf8ba042cb291 (diff)
downloadgcc-76008ac42aa83a8051d9cf9d9e2106099aec90df.tar.gz
PR c++/30847
* typeck.c (build_modify_expr): For COND_EXPR on LHS, if RHS has void type issue error and return early. * g++.dg/parse/cond3.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123456 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c6
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/parse/cond3.C15
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 755115e4a93..192d7e8adfb 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2007-04-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/30847
+ * typeck.c (build_modify_expr): For COND_EXPR on LHS, if RHS has void
+ type issue error and return early.
+
2007-03-30 Jason Merrill <jason@redhat.com>
PR c++/31187
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a5a33451cf9..f3358c79c6c 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5702,6 +5702,12 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
tree cond;
tree preeval = NULL_TREE;
+ if (VOID_TYPE_P (TREE_TYPE (rhs)))
+ {
+ error ("void value not ignored as it ought to be");
+ return error_mark_node;
+ }
+
rhs = stabilize_expr (rhs, &preeval);
/* Check this here to avoid odd errors when trying to convert
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5570d4806da..74691d270a6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2007-04-03 Jakub Jelinek <jakub@redhat.com>
+ PR c++/30847
+ * g++.dg/parse/cond3.C: New test.
+
PR middle-end/30704
* gcc.c-torture/execute/ieee/pr30704.c: New test.
diff --git a/gcc/testsuite/g++.dg/parse/cond3.C b/gcc/testsuite/g++.dg/parse/cond3.C
new file mode 100644
index 00000000000..96d9c1e3b5f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/cond3.C
@@ -0,0 +1,15 @@
+// PR c++/30847
+// { dg-do compile }
+// { dg-options "" }
+
+int j, k, l;
+extern void baz ();
+
+void
+foo (int i)
+{
+ (i ? j : k) = ({ l++; (void) l; }); // { dg-error "void value not ignored" }
+ (i ? j : k) += ({ l++; (void) l; }); // { dg-error "void value not ignored" }
+ (i ? j : k) = baz (); // { dg-error "void value not ignored" }
+ (i ? j : k) *= baz (); // { dg-error "void value not ignored" }
+}