[cfe-dev] Spurious warning: unused parameter when used only in an expression error-ing out

Matthieu Monrocq matthieu.monrocq at gmail.com
Fri Jul 15 09:52:17 PDT 2011


2011/7/14 Ted Kremenek <kremenek at apple.com>

> We should probably not emit a -Wunused-[x] warning in cases where a
> function doesn't fully parse correctly.  Please file a bug.
>
>
Done: http://llvm.org/bugs/show_bug.cgi?id=10371


> On Jul 14, 2011, at 12:34 PM, Matthieu Monrocq wrote:
>
> Hello clang,
>
> I made a strange discovery with a small helper function I wrote:
>
> If one test the following (short) program:
>
> struct A;
>
> void sink(A,int);
>
> void func(A const& a, int x, int y) {
>    sink(a + x, y);
> }
>
> The following errors get emitted:
>
> $ clang -fsyntax-only -Wunused-parameter unused_parameter.cpp
> unused_parameter.cpp:15:11: error: invalid operands to binary expression
> ('const A' and 'int')
>    sink(a + x, y);
>         ~ ^ ~
> unused_parameter.cpp:14:34: warning: unused parameter 'y'
> [-Wunused-parameter]
> void func(A const& a, int x, int y) {
>                                  ^
> 1 warning and 1 error generated.
>
>
> 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...
>
> I feel that this is unwelcome, because it obfuscates the true error
> (especially since I tend to compile with -Werror).
>
>
> For reference, I use the following version of Clang:
>
> $ clang --version
> clang version 3.0 (trunk 132889)
> Target: i686-pc-mingw32
> Thread model: posix
>
> 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.
>
> -- Matthieu
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110715/5bd41c5c/attachment.html>


More information about the cfe-dev mailing list