* [C++ PATCH] Avoid bogus -Wunused-value warnings (PR c++/39875)
@ 2009-04-26 21:01 Jakub Jelinek
2009-04-26 22:59 ` Mark Mitchell
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2009-04-26 21:01 UTC (permalink / raw)
To: Jason Merrill, Mark Mitchell; +Cc: gcc-patches
Hi!
For PR c++/39551 g++ started warning about INDIRECT_REFs in
convert_to_void, but we shouldn't be warning when the cast to (void)
is explicit in the program, only when convert_to_void is called
implicitly. I believe we can use the IMPLICIT argument of convert_to_void
for this.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2009-04-26 Jakub Jelinek <jakub@redhat.com>
PR c++/39875
* cvt.c (convert_to_void) <case INDIRECT_REF>: Only warn about
-Wunused-value if implicit.
--- gcc/cp/cvt.c.jj 2009-04-16 10:11:00.000000000 +0200
+++ gcc/cp/cvt.c 2009-04-26 21:27:22.000000000 +0200
@@ -878,6 +878,7 @@ convert_to_void (tree expr, const char *
- 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)
--- gcc/testsuite/g++.dg/warn/Wunused-15.C.jj 2009-04-26 21:30:28.000000000 +0200
+++ gcc/testsuite/g++.dg/warn/Wunused-15.C 2009-04-26 21:29:11.000000000 +0200
@@ -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" }
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] Avoid bogus -Wunused-value warnings (PR c++/39875)
2009-04-26 21:01 [C++ PATCH] Avoid bogus -Wunused-value warnings (PR c++/39875) Jakub Jelinek
@ 2009-04-26 22:59 ` Mark Mitchell
0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2009-04-26 22:59 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jason Merrill, gcc-patches
Jakub Jelinek wrote:
> 2009-04-26 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/39875
> * cvt.c (convert_to_void) <case INDIRECT_REF>: Only warn about
> -Wunused-value if implicit.
OK.
While we're here, let's improve the convert_to_void documentation.
In particular, instead of:
IMPLICIT is tells us the context of an implicit void conversion. */
Let's say:
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.
That's not a very i18n friendly interface, but at least it's a better
documentation of the existing interface.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-04-26 22:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-26 21:01 [C++ PATCH] Avoid bogus -Wunused-value warnings (PR c++/39875) Jakub Jelinek
2009-04-26 22:59 ` Mark Mitchell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).