aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-08-23 17:53:18 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2011-08-23 17:53:18 +0200
commit09e640b34df2fd4f0413f6984194606e97191292 (patch)
tree7fbdac5f555fe09d1f934920f03823bfd1fdcfbb /gcc/cp
parente2f008377225f76538d728cb16772e29091feb0f (diff)
downloadgcc-09e640b34df2fd4f0413f6984194606e97191292.zip
gcc-09e640b34df2fd4f0413f6984194606e97191292.tar.gz
gcc-09e640b34df2fd4f0413f6984194606e97191292.tar.bz2
re PR c++/50158 (invalid 'variable set but not used' warning (boolean used as an index to an array))
PR c++/50158 * typeck.c (cp_build_modify_expr): Call mark_rvalue_use on rhs if it has side-effects and needs to be preevaluated. * g++.dg/warn/Wunused-var-16.C: New test. From-SVN: r177992
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c2
2 files changed, 8 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5ebab87..39f1d31 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2011-08-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/50158
+ * typeck.c (cp_build_modify_expr): Call mark_rvalue_use on rhs
+ if it has side-effects and needs to be preevaluated.
+
2011-08-23 Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
PR c++/50055
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a1f6761..4c130ee 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6692,6 +6692,8 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
side effect associated with any single compound assignment
operator. -- end note ] */
lhs = stabilize_reference (lhs);
+ if (TREE_SIDE_EFFECTS (rhs))
+ rhs = mark_rvalue_use (rhs);
rhs = stabilize_expr (rhs, &init);
newrhs = cp_build_binary_op (input_location,
modifycode, lhs, rhs,