<div style="font-family: arial, helvetica, sans-serif"><font size="2">FYI, this in <a href="http://llvm.org/PR4802">http://llvm.org/PR4802</a><div><br></div><div>You might want to drop a note there in case anyone else is looking at this.<br>
<br><div class="gmail_quote">On Wed, Jun 20, 2012 at 2:53 AM, Igor Minin <span dir="ltr"><<a href="mailto:i.minin.llvm@gmail.com" target="_blank">i.minin.llvm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello.<br><br><div>The attached patch adds support for a clang -Wcast-qual option. Semantic is compatible with the gcc one.<br><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">

Warn whenever a pointer is cast so as to remove a type qualifier from the target<br>type. For example, warn if a "const char*" is cast to an ordinary "char*".<br>Also warn when making a cast that introduces a type qualifier in an unsafe way.<br>

For example, casting "char**" to "const char**" is unsafe, as in this example:<br>/* p is char ** value. */<br>const char **q = (const char **) p;<br>/* Assignment of readonly string to const char * is OK. */<br>

*q = "string";<br>/* Now char** pointer points to read-only memory. */<br>**p = ’b’;</blockquote>(Gcc manual).<br><br>What is "introducing in an unsafe way" precisely described in [conv.qual] item of C++ standard. <div>

<br>So, the proposed patch is very similar to the code that checks assign constrains. Differences are: </div><div><br> * This patch generates only warnings, not errors, which helps to have cleaner implementation.<br> * It is called only for C-style casting and functional-style casting (because only three casts can remove qualifiers: C-sytle, functional-style and const_cast. But const_cast in gcc is not generated warnings, so I preserved this behaviour in clang). Other cases filtered by checks in appropriate casts.</div>

<div><br>Please, review.</div></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></div></font></div>