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

Lubos Lunak l.lunak at suse.cz
Sat Jul 20 16:24:11 PDT 2013


On Tuesday 16 of July 2013, Lubos Lunak wrote:
> On Tuesday 16 of July 2013, Lubos Lunak wrote:
> > On Tuesday 16 of July 2013, Richard Smith wrote:
> > > 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:
> > > > > 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?)
> >
> >  I think you are talking about something slightly different. This is
> > about the (-W)unused-variable warning. So A and C obviously don't apply.
>
>  But since you ask, without looking at the code, presumably
> (-W)unused-result has code similar to unused-variable that also disables
> the warning if the type in question has non-trivial ctor/dtor, so you could
> do a similar modification there to enable the warning for types with
> warn_unused attribute.

 The attached patch adds this functionality for the -Wunused-value warning.

-- 
 Lubos Lunak
 l.lunak at suse.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-report-unused-value-warning-also-for-warn_unused-typ.patch
Type: text/x-diff
Size: 1871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130721/6278ca85/attachment.patch>


More information about the cfe-commits mailing list