Commit 7409e5a5 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/39875 (Wrong "value computed is not used" warning)

	PR c++/39875
	* cvt.c (convert_to_void) <case INDIRECT_REF>: Only warn about
	-Wunused-value if implicit.

	* g++.dg/warn/Wunused-15.C: New test.

From-SVN: r146825
parent 5bb786b0
2009-04-27 Jakub Jelinek <jakub@redhat.com>
PR c++/39875
* cvt.c (convert_to_void) <case INDIRECT_REF>: Only warn about
-Wunused-value if implicit.
2009-04-24 Ian Lance Taylor <iant@google.com>
* call.c (build_temp): Change 0 to enum constant.
......
......@@ -787,7 +787,10 @@ ocp_convert (tree type, tree expr, int convtype, int flags)
make it impossible to ignore the reference return value from functions. We
issue warnings in the confusing cases.
IMPLICIT is tells us the context of an implicit void conversion. */
IMPLICIT is non-NULL iff an expression is being implicitly converted; it
is NULL when the user is explicitly converting an expression to void via
a cast. When non-NULL, IMPLICIT is a string indicating the context of
the implicit conversion. */
tree
convert_to_void (tree expr, const char *implicit, tsubst_flags_t complain)
......@@ -885,6 +888,7 @@ convert_to_void (tree expr, const char *implicit, tsubst_flags_t complain)
- automatic dereferencing of references, since the user cannot
control it. (See also warn_if_unused_value() in stmt.c.) */
if (warn_unused_value
&& implicit
&& (complain & tf_warning)
&& !TREE_NO_WARNING (expr)
&& !is_reference)
......
2009-04-27 Jakub Jelinek <jakub@redhat.com>
PR c++/39875
* g++.dg/warn/Wunused-15.C: New test.
2009-04-26 Michael Matz <matz@suse.de>
Expand from SSA.
......
// PR c++/39875
// { dg-do compile }
// { dg-options "-Wunused-value" }
int *i;
void
foo ()
{
*i++; // { dg-warning "value computed is not used" }
(void) *i++; // { dg-bogus "value computed is not used" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment