[cfe-dev] Usefull warnings

Richard Smith richard at metafoo.co.uk
Mon Apr 21 10:38:59 PDT 2014


See http://llvm.org/bugs/show_bug.cgi?id=18938


On Mon, Apr 21, 2014 at 8:07 AM, Fernando Pelliccioni <
fpelliccioni at gmail.com> wrote:

> Sorry!
>
> lock = look
>
> Please, don't look the attached file using Google Preview. Download it and
> open it with your favorite text editor.
>
>
> On Mon, Apr 21, 2014 at 12:06 PM, Fernando Pelliccioni <
> fpelliccioni at gmail.com> wrote:
>
>> 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.
>>>
>>
>>
>
> _______________________________________________
> 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/20140421/dc3b7ed4/attachment.html>


More information about the cfe-dev mailing list