* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177992
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
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,
2011-08-23 Jakub Jelinek <jakub@redhat.com>
+ PR c++/50158
+ * g++.dg/warn/Wunused-var-16.C: New test.
+
PR middle-end/50161
* gcc.dg/pr50161.c: New test.
--- /dev/null
+// PR c++/50158
+// { dg-do compile }
+// { dg-options "-Wunused" }
+
+int bar (int);
+
+int
+foo (int a)
+{
+ int b[] = { a, -a };
+ a += b[bar (a) < a];
+ return a;
+}