diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wunused-15.C | 11 |
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e15834d..3feda53 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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. diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 6d35245..c86fbdf 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4e1816a..b5beac2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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. diff --git a/gcc/testsuite/g++.dg/warn/Wunused-15.C b/gcc/testsuite/g++.dg/warn/Wunused-15.C new file mode 100644 index 0000000..efaebc0 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-15.C @@ -0,0 +1,11 @@ +// 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" } +} |