<div dir="ltr">This is just a matter of ordering:<br><br><div>$ clang++-tot unused.cpp -Werror -Wno-error=unused-parameter -Wunused-parameter</div><div>unused.cpp:2:17: error: unused parameter 'i' [-Werror,-Wunused-parameter]</div>
<div> void func(int i) {</div><div> ^</div><div>1 error generated.</div><div><br></div><div><div>$ clang++-tot unused.cpp -Wextra -Werror -Wno-error=unused-parameter</div><div>unused.cpp:2:17: warning: unused parameter 'i' [-Wunused-parameter]</div>
<div> void func(int i) {</div><div> ^</div><div>1 warning generated.<br><br>Which differs from GCC, which warns in both cases. This is arguably (not sure if the Clang behavior is intentional) a bug in Clang. Feel free to file it at <a href="http://llvm.org/bugs">llvm.org/bugs</a> - in the mean time you can workaround it by putting the -Werror related flags last.</div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 11, 2013 at 7:13 PM, Eric Levy <span dir="ltr"><<a href="mailto:contact@ericlevy.name" target="_blank">contact@ericlevy.name</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Evidently my build is not behaving the same way, as demonstrated below. Version information is also shown.<br>
<br>
<br>
% clang -c -m64 -pipe -std=c++0x -Werror -Wno-error=unused-parameter -g -fPIC -Wall -W -D_REENTRANT -DQT_XMLPATTERNS_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_XML_LIB -DQT_CORE_LIB -I/opt/qt-5.0.0-linux64-<u></u>ubuntu1204-gcc/mkspecs/linux-<u></u>g++-64 -I../src -I/opt/qt-5.0.0-linux64-<u></u>ubuntu1204-gcc/include -I/opt/qt-5.0.0-linux64-<u></u>ubuntu1204-gcc/include/<u></u>QtXmlPatterns -I/opt/qt-5.0.0-linux64-<u></u>ubuntu1204-gcc/include/<u></u>QtConcurrent -I/opt/qt-5.0.0-linux64-<u></u>ubuntu1204-gcc/include/<u></u>QtNetwork -I/opt/qt-5.0.0-linux64-<u></u>ubuntu1204-gcc/include/QtXml -I/opt/qt-5.0.0-linux64-<u></u>ubuntu1204-gcc/include/QtCore -I. -I. -o ../obj/QDavResource.o ../src/QDavResource.cpp<br>
../src/QDavResource.cpp:12:60: error: unused parameter 'propList'<br>
[-Werror,-Wunused-parameter]<br>
void QDavResource::setPropertyList(<u></u>const QDavPropertyList* propList) {<br>
^<br>
1 error generated.<br>
<br>
<br>
% clang -v<br>
Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)<br>
Target: x86_64-pc-linux-gnu<br>
Thread model: posix<div class="im"><br>
<br>
<br>
On 10/11/2013 10:00 PM, David Blaikie wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
<br>
<br>
On Fri, Oct 11, 2013 at 6:58 PM, Eric Levy <<a href="mailto:contact@ericlevy.name" target="_blank">contact@ericlevy.name</a><br></div><div class="im">
<mailto:<a href="mailto:contact@ericlevy.name" target="_blank">contact@ericlevy.name</a>><u></u>> wrote:<br>
<br>
I stand corrected on the -Werror/-Wall issue.<br>
<br>
With respect to unused parameters, I do have -Wall enabled, however,<br>
the documentation states I can override it on particular types of<br>
warnings using -Wno-error=foo (this part is definitely different<br>
from gcc), however, I have been unsuccessful in doing so.<br>
<br>
<br>
I demonstrated that in my example:<br>
<br>
$ clang++-tot unused.cpp -Wextra -Werror -Wno-error=unused-parameter<br>
unused.cpp:2:17: warning: unused parameter 'i' [-Wunused-parameter]<br>
void func(int i) {<br>
^<br>
1 warning generated.<br>
<br>
demoting the unused-parameter warning back from an error to a warning,<br>
worked for me. You do need to use the exact warning name, not a warning<br>
group (eg: -Wno-error=unused or -Wno-error=all won't work).<br>
<br>
<br>
Eric Levy<br>
<br>
<br>
<br>
On 10/11/2013 09:49 PM, David Blaikie wrote:<br>
<br>
<br>
<br>
<br>
On Fri, Oct 11, 2013 at 6:34 PM, Eric Levy<br>
<<a href="mailto:contact@ericlevy.name" target="_blank">contact@ericlevy.name</a> <mailto:<a href="mailto:contact@ericlevy.name" target="_blank">contact@ericlevy.name</a>><br></div>
<mailto:<a href="mailto:contact@ericlevy.name" target="_blank">contact@ericlevy.name</a> <mailto:<a href="mailto:contact@ericlevy.name" target="_blank">contact@ericlevy.name</a>><u></u>>__><div><div class="h5">
<br>
wrote:<br>
<br>
Hello,<br>
<br>
I began to experiment with clang to build an existing C++<br>
(Qt-based)<br>
project. I wanted to make warnings into errors in order to<br>
ensure<br>
that the code is solid. However, there are several issues:<br>
<br>
1) Clang is said to be designed to have the same command-line<br>
interface as gcc, but the options for warnings and errors are<br>
different. The gcc command -Wall is -Werror in clang, and<br>
so on.<br>
<br>
<br>
Actually Clang and GCC both have -Wall and -Werror and they do<br>
(roughly)<br>
the same thing in each. -Wall is the "common likely-good<br>
warnings" and<br>
-Werror is "whatever warnings are on, make them errors". The<br>
specific<br>
set of things in -Wall differs somewhat between Clang and GCC since<br>
there's no specific definition, but roughly speaking those flags<br>
do the<br>
same thing.<br>
<br>
<br>
2) The user documentation states that specific warnings can<br>
be made<br>
into errors or not errors by using the -Werror=foo and<br>
-Wno-error=foo options. However, no list of accepted<br>
values for foo<br>
is given.<br>
<br>
<br>
This is a flaw in Clang's documentation - we basically don't<br>
document<br>
our flags, so far as I know. You guess them, or you look at the<br>
implementation, or try -Weverything (turns on all warnings) and<br>
see what<br>
warnings fire and what their flags are called (we print the flag<br>
name by<br>
default).<br>
<br>
<br>
3) Finally, gcc/clang both warn on unused variables and<br>
parameters.<br>
This often undesired, especially in C++ where, due to<br>
polymorphism<br>
some implementations of a method may not need certain<br>
parameters.<br>
<br>
<br>
I don't believe Clang warns on unused parameters by default, if<br>
at all.<br>
If it does so on virtual functions that's probably a bug to be<br>
fixed.<br>
<br>
When clang produces an error for unused parameters (-Werror<br>
enabled), it reports the reason is -Wunused-parameter.<br>
However,<br>
introducing -Wno-error=unused-parameter has no effect, despite<br>
documentation to the contrary. The gcc-style<br>
-Wno-unused-parameter<br>
is equally ineffective.<br>
<br>
<br>
Could you show examples of this?<br>
<br>
-Wunused-parameter isn't under -Wall, so you must've passed it<br>
explicitly I assume (or perhaps via -Wextra)?<br>
<br>
All these options seem to work quite well for me with Clang:<br>
<br>
$ clang++-tot unused.cpp -Wextra<br>
unused.cpp:2:17: warning: unused parameter 'i' [-Wunused-parameter]<br>
void func(int i) {<br>
^<br>
1 warning generated.<br>
$ clang++-tot unused.cpp -Wextra -Werror<br>
unused.cpp:2:17: error: unused parameter 'i'<br>
[-Werror,-Wunused-parameter]<br>
void func(int i) {<br>
^<br>
1 error generated.<br>
$ clang++-tot unused.cpp -Wextra -Werror -Wno-error=unused-parameter<br>
unused.cpp:2:17: warning: unused parameter 'i' [-Wunused-parameter]<br>
void func(int i) {<br>
^<br>
1 warning generated.<br>
$ clang++-tot unused.cpp -Wextra -Werror -Wno-unused-parameter<br>
$<br>
<br>
So too is replacing unused-parameter with simply unused,<br>
which, at<br>
least according to gcc documentation, subsumes unused<br>
variables and<br>
parameters alike.<br>
<br>
Whether these observations represent choice or oversight, I<br>
would<br>
like to know how to make all warnings errors except for unused<br>
variables and parameters.<br>
<br>
Thank you.<br>
<br>
Sincerely,<br>
Eric Levy<br></div></div>
______________________________<u></u>_____________________<div class="im"><br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@cs.uiuc.edu" target="_blank">cfe-users@cs.uiuc.edu</a> <mailto:<a href="mailto:cfe-users@cs.uiuc.edu" target="_blank">cfe-users@cs.uiuc.edu</a>><br></div>
<mailto:<a href="mailto:cfe-users@cs.uiuc.edu" target="_blank">cfe-users@cs.uiuc.edu</a> <mailto:<a href="mailto:cfe-users@cs.uiuc.edu" target="_blank">cfe-users@cs.uiuc.edu</a>><u></u>><br>
<a href="http://lists.cs.uiuc.edu/____mailman/listinfo/cfe-users" target="_blank">http://lists.cs.uiuc.edu/____<u></u>mailman/listinfo/cfe-users</a><br>
<<a href="http://lists.cs.uiuc.edu/__mailman/listinfo/cfe-users" target="_blank">http://lists.cs.uiuc.edu/__<u></u>mailman/listinfo/cfe-users</a>><br>
<<a href="http://lists.cs.uiuc.edu/__mailman/listinfo/cfe-users" target="_blank">http://lists.cs.uiuc.edu/__<u></u>mailman/listinfo/cfe-users</a><br>
<<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-users</a>>><br>
<br>
<br>
<br>
</blockquote>
</blockquote></div><br></div>