<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 11, 2013 at 6:34 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello,<br>
<br>
I began to experiment with clang to build an existing C++ (Qt-based) project.  I wanted to make warnings into errors in order to ensure 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 interface as gcc, but the options for warnings and errors are different.  The gcc command -Wall is -Werror in clang, and so on.<br></blockquote><div><br></div>
<div>Actually Clang and GCC both have -Wall and -Werror and they do (roughly) the same thing in each. -Wall is the "common likely-good warnings" and -Werror is "whatever warnings are on, make them errors". The specific set of things in -Wall differs somewhat between Clang and GCC since there's no specific definition, but roughly speaking those flags do the same thing.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
2) The user documentation states that specific warnings can be made into errors or not errors by using the -Werror=foo and -Wno-error=foo options.  However, no list of accepted values for foo is given.<br></blockquote><div>
<br></div><div>This is a flaw in Clang's documentation - we basically don't document our flags, so far as I know. You guess them, or you look at the implementation, or try -Weverything (turns on all warnings) and see what warnings fire and what their flags are called (we print the flag name by default).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
3) Finally, gcc/clang both warn on unused variables and parameters. This often undesired, especially in C++ where, due to polymorphism some implementations of a method may not need certain parameters.</blockquote><div><br>
</div><div>I don't believe Clang warns on unused parameters by default, if at all. If it does so on virtual functions that's probably a bug to be fixed.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  When clang produces an error for unused parameters (-Werror enabled), it reports the reason is -Wunused-parameter.  However, introducing -Wno-error=unused-parameter has no effect, despite documentation to the contrary.  The gcc-style -Wno-unused-parameter is equally ineffective. </blockquote>
<div><br></div><div>Could you show examples of this?<br><br>-Wunused-parameter isn't under -Wall, so you must've passed it explicitly I assume (or perhaps via -Wextra)?<br><br>All these options seem to work quite well for me with Clang:<br>
<br><div>$ clang++-tot unused.cpp -Wextra</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.</div>
<div>$ clang++-tot unused.cpp -Wextra -Werror</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>$ 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.</div><div>$ clang++-tot unused.cpp -Wextra -Werror -Wno-unused-parameter</div><div>$ </div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
So too is replacing unused-parameter with simply unused, which, at least according to gcc documentation, subsumes unused variables and parameters alike.<br>
<br>
Whether these observations represent choice or oversight, I would like to know how to make all warnings errors except for unused variables and parameters.<br>
<br>
Thank you.<br>
<br>
Sincerely,<br>
Eric Levy<br>
______________________________<u></u>_________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@cs.uiuc.edu" target="_blank">cfe-users@cs.uiuc.edu</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>
</blockquote></div><br></div></div>