On Tue, Jul 16, 2013 at 2:17 PM, Lubos Lunak <span dir="ltr"><<a href="mailto:l.lunak@suse.cz" target="_blank">l.lunak@suse.cz</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On Tuesday 16 of July 2013, Richard Smith wrote:<br>
> On Tue, Jul 16, 2013 at 12:50 PM, Lubos Lunak <<a href="mailto:l.lunak@suse.cz" target="_blank">l.lunak@suse.cz</a>> wrote:<br>
> > On Tuesday 16 of July 2013, Richard Smith wrote:<br>
</div><div>> > > Consider:<br>
> > ><br>
> > > {<br>
> > >   my_lock(my_mutex); // A<br>
> > >   my_lock ml(my_mutex); // B<br>
> > >   my_string("foo"); // C<br>
> > >   my_string ms("foo"); // D<br>
> > > }<br>
> > ><br>
> > > We never warn for a class that is in category (1). my_lock would be in<br>
> > > category (2), so we warn on A but not B. my_string would be in category<br>
> > > (3), so we warn on both C and D.<br>
> > ><br>
> > > Which of these does the warn_unused attribute model?<br>
> ><br>
> >  It doesn't model anything. It prevents disabling of the unused-variable<br>
> > warning for whatever type that has the attribute.<br>
><br>
> So which of the above behaviors do you get? (Or do you get something else?)<br>
<br>
</div> I think you are talking about something slightly different. This is about the<br>
(-W)unused-variable warning. So A and C obviously don't apply. B and D will<br>
cause the warning if the relevant variable has at most trivial ctor/dtor<br>
called (before my patch), or has at most even non-trivial ctor/dtor called<br>
but also has the attribute set (added by the patch). That's all.</blockquote><div><br></div><div>OK, thanks. I think that this means the semantics of your attribute correspond to my category (3) (that is, it means that the ctor and dtor have no external side effects).</div>
<div><br></div><div>Some trivial pedantry below, but otherwise LGTM.</div><div><br></div><div><div>--- a/include/clang/Basic/Attr.td</div><div>+++ b/include/clang/Basic/Attr.td</div><div>@@ -749,6 +749,10 @@ def VecReturn : InheritableAttr {</div>
<div>   let Subjects = [CXXRecord];</div><div> }</div><div> </div><div>+def WarnUnused : InheritableAttr {</div><div>+  let Spellings = [GNU<"warn_unused">, CXX11<"gnu", "warn_unused">];</div>
<div>+}</div></div><div><br></div><div>Please add</div><div><br></div><div>  let Subjects = [Record];</div><div><br></div><div>to this. Subjects has no effect yet, but we're in the process of switching to automatically generating the "does this attribute appertain to this entity" code.</div>
<div><br></div><div><div>--- a/lib/Sema/SemaDeclAttr.cpp</div><div>+++ b/lib/Sema/SemaDeclAttr.cpp</div><div>@@ -2669,6 +2669,17 @@ static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &Attr) {</div>
<div>                           Attr.getAttributeSpellingListIndex()));</div><div> }</div><div> </div><div>+static void handleWarnUnusedAttr(Sema &S, Decl *D, const AttributeList &Attr) {</div><div>+  // check the attribute arguments.</div>
</div><div><br></div><div>Please capitalize this comment.</div><div><br></div><div>Thanks!</div>
</div>