[cfe-commits] r158411 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaDeclCXX.cpp test/SemaCXX/warn-unused-member.cpp

Daniel Jasper djasper at google.com
Wed Jun 20 23:12:46 PDT 2012


I have looked into both suggestions, but I am not sure what the right thing
is:

__attribute__((used)): According to the gcc docs, "this attribute, attached
to a function, means that code must be emitted for the function even if it
appears that the function is not referenced". It doesn't really say
anything about silencing warnings and the code emitting part does not
really apply to fields. I am happy to make this attribute silence the
warning, but I don't know whether that makes sense.

-Wused-but-marked-unused: We run into trouble if certain field usages are
only conditionally included (#ifdefs, ...).  In that case, it would be
impossible to create source code that produces neither
-Wused-but-marked-unused nor -Wunused-private-field if compiled in
different modes.

Any thoughts?
Daniel

On Thu, Jun 14, 2012 at 7:11 PM, Jordan Rose <jordan_rose at apple.com> wrote:

>
> On Jun 13, 2012, at 12:21 PM, Jonathan Sauer wrote:
>
> > Hello,
> >
> >>> Allow __attribute__((unused)) for fields and make it silence
> >>> -Wunused-private-field.
> >>
> >> So that these annotations don't get out of date, should we warn when a
> >> field is marked unused but is, in fact, used? (so that when it becomes
> >> used the attribute is cleaned up and doesn't lead to the function
> >> being accidentally unused again in the future)
> >
> > There already is a warning for this, -Wused-but-marked-unused, which is
> emitted
> > when a function marked unused is being used. I think it should be the
> same with
> > fields.
>
> I agree. Similarly, __attribute__((used)) ought to silence the warning
> whether we find an actual use or not.
>
> (Sorry I didn't think of this in my pre-commit review.)
>
> Jordan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120621/7f19415b/attachment.html>


More information about the cfe-commits mailing list