<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">We should probably not emit a -Wunused-[x] warning in cases where a function doesn't fully parse correctly.  Please file a bug.<br><div><br><div><div>On Jul 14, 2011, at 12:34 PM, Matthieu Monrocq wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hello clang,<br><br>I made a strange discovery with a small helper function I wrote:<br><br>If one test the following (short) program:<br><br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">struct A;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">void sink(A,int);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">void func(A const& a, int x, int y) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   sink(a + x, y);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br></div><br>The following errors get emitted:<br>
<br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">$ clang -fsyntax-only -Wunused-parameter unused_parameter.cpp</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">unused_parameter.cpp:15:11: error: invalid operands to binary expression ('const A' and 'int')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   sink(a + x, y);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        ~ ^ ~</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">unused_parameter.cpp:14:34: warning: unused parameter 'y' [-Wunused-parameter]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">void func(A const& a, int x, int y) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                                 ^</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">1 warning and 1 error generated.</span><br>
</div><br><br>The first one is expected, however it seems its presence somehow short-circuit the analysis of the whole expression and as a result we get the spurious warning...<br><br>I feel that this is unwelcome, because it obfuscates the true error (especially since I tend to compile with -Werror).<br>
<br><br>For reference, I use the following version of Clang:<br><br>$ clang --version<br>clang version 3.0 (trunk 132889)<br>Target: i686-pc-mingw32<br>Thread model: posix<br><br>I could not find any mention of such an issue with my Google-fu in the cfe-dev archive, so please let me know if it already came up and it was deemed unimportant.<br>
<br>-- Matthieu<br>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></blockquote></div><br></div></body></html>