On Tue, Jul 16, 2013 at 12:50 PM, Lubos Lunak <[email protected]> wrote:
> On Tuesday 16 of July 2013, Richard Smith wrote: > > On Tue, Jul 16, 2013 at 10:45 AM, David Blaikie <[email protected]> > 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?)
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
