[PATCH] PR14253: 'warn_unused' attribute for unused warning for non-POD types

Richard Smith richard at metafoo.co.uk
Tue Jul 16 13:52:32 PDT 2013


On Tue, Jul 16, 2013 at 12:50 PM, Lubos Lunak <l.lunak at suse.cz> wrote:

> On Tuesday 16 of July 2013, Richard Smith wrote:
> > On Tue, Jul 16, 2013 at 10:45 AM, David Blaikie <dblaikie at gmail.com>
> wrote:
> > > I know we'd previously discussed the idea of being able to warn about
> > > unused variables of non-trivial types - you'd gone so far as to
> > > suggest the idea of a positive attribute (annotate the classes that
> > > have side effects, rather than those that don't, since the former
> > > seems like the exception rather than the rule).
> >
> > Right. We usually try to stay on the side of no-false-positives, but in
> > this case diligent users would find themselves annotating nearly all
> > classes, and that doesn't seem like a good tradeoff.
>
>  I'd rather worry about those that won't be dilligent.
>
> > Also, we identified
> > that there are at least three different kinds of class here:
> >
> >  1) Those where the ctor and/or the dtor has external, permanent
> > side-effects (probably very rare)
> >  2) Those where the ctor or dtor have external, temporary side-effects,
> but
> > running one then the other is essentially equivalent to running neither
> > (for instance, many RAII objects follow this pattern)
> >  3) Those where the ctor and dtor have no external side-effects
> >
> > Consider:
> >
> > {
> >   my_lock(my_mutex); // A
> >   my_lock ml(my_mutex); // B
> >   my_string("foo"); // C
> >   my_string ms("foo"); // D
> > }
> >
> > We never warn for a class that is in category (1). my_lock would be in
> > category (2), so we warn on A but not B. my_string would be in category
> > (3), so we warn on both C and D.
> >
> > Which of these does the warn_unused attribute model?
>
>  It doesn't model anything. It prevents disabling of the unused-variable
> warning for whatever type that has the attribute.


So which of the above behaviors do you get? (Or do you get something else?)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130716/8b83ec4b/attachment.html>


More information about the cfe-commits mailing list