<div style="font-family: arial, helvetica, sans-serif"><font size="2"><div class="gmail_quote">On Wed, Jun 20, 2012 at 11:12 PM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif"><font size="2">I have looked into both suggestions, but I am not sure what the right thing is:<div>
<br></div><div>__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.</div>

<div><br></div><div>-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.</div>

<div><br></div><div>Any thoughts?</div></font></div></blockquote><div><br></div><div>I really should have thought of this when we chatted. It's quite verbose, but it works:</div><div><br></div><div><font face="courier new, monospace">struct S {</font></div>
<div><font face="courier new, monospace">  int platform_specific_member</font></div><div><font face="courier new, monospace">#ifdef __x86_64__</font></div><div><font face="courier new, monospace">    __attribute__((unused))</font></div>
<div><font face="courier new, monospace">#endif</font></div><div><font face="courier new, monospace">    ;</font></div><div><font face="courier new, monospace">};</font></div><div><br></div><div><br></div><div>We just have to make the attribute itself be conditioned on the same thing as the use of the member. As long as this attribute never impacts semantics, this should be fine. Do others thing this is too cumbersome?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif"><font size="2"><div><span class="HOEnZb"><font color="#888888"><br>
Daniel</font></span></div><div class="im"><div><br><div class="gmail_quote">On Thu, Jun 14, 2012 at 7:11 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br>
On Jun 13, 2012, at 12:21 PM, Jonathan Sauer wrote:<br>
<br>
> Hello,<br>
><br>
>>> Allow __attribute__((unused)) for fields and make it silence<br>
>>> -Wunused-private-field.<br>
>><br>
>> So that these annotations don't get out of date, should we warn when a<br>
>> field is marked unused but is, in fact, used? (so that when it becomes<br>
>> used the attribute is cleaned up and doesn't lead to the function<br>
>> being accidentally unused again in the future)<br>
><br>
> There already is a warning for this, -Wused-but-marked-unused, which is emitted<br>
> when a function marked unused is being used. I think it should be the same with<br>
> fields.<br>
<br>
</div>I agree. Similarly, __attribute__((used)) ought to silence the warning whether we find an actual use or not.<br>
<br>
(Sorry I didn't think of this in my pre-commit review.)<br>
<span><font color="#888888"><br>
Jordan<br>
</font></span></blockquote></div><br></div></div></font></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></font></div>