[cfe-dev] Usefull warnings

Fernando Pelliccioni fpelliccioni at gmail.com
Mon Apr 21 08:06:38 PDT 2014


Please, don't lock the attached file using Google Preview. Download it and
open it with your favorite text editor.


On Mon, Apr 21, 2014 at 12:04 PM, Fernando Pelliccioni <
fpelliccioni at gmail.com> wrote:

> Hi all,
>
> The following code snippet is related to the Apple bug of a few weeks ago.
>
> void foo();
> void bar();
>
> void test( int a )
> {
> if ( a == 1 )
> foo();
> bar();
> }
>
> The original source code of the Apple bug has Goto's instead of function
> calls, but the problem is essentially the same, and it is related to
> scoping.
>
> I wonder if you considered convenient adding a warning if Clang detects
> that a line is indented so that does not match the natural indentation of
> its scope, especially there are a conditional around.
>
>
> The following code is fine, no problem with it.
> void test2()
> {
> foo();
> bar();
> }
>
>
> I think the followings cases should be warned by the compiler.
> void test3()
> {
> while (true) foo();
>  bar();
> }
>
> void test4()
> {
> if (true) foo();
> bar();
> }
>
> To emphasize the problem I attached a source code file. Could you give it
> a quick look and tell me what is printed out?
> I know that it is an extreme and malicious example, but it help us to
> understand that when we given a quick look to the code, we can ignore cases
> like these.
>
>
> Do you think it would be useful to add these warnings to Clang?
>
> Thanks and regards,
> Fernando Pelliccioni.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140421/424c9a1f/attachment.html>


More information about the cfe-dev mailing list