[cfe-commits] [PATCH] Warn on function-to-bool conversion.

Lang Hames lhames at gmail.com
Thu Dec 1 19:16:05 PST 2011


Hi Richard,

I've added source ranges to the diagnostic, however I'm wary of catching
cases like

if (&foo) {}

That seems too deliberate. For now I'd prefer to stick to the simple case
of missing parentheses.

What do you think?

Cheers,
Lang.

On Mon, Nov 28, 2011 at 3:12 PM, Richard Trieu <rtrieu at google.com> wrote:

> On Mon, Nov 28, 2011 at 1:38 PM, Lang Hames <lhames at gmail.com> wrote:
>
>> This patch adds a warning for implicit conversion from functions to
>> booleans.
>>
>> Could someone take a look and let me know if anything needs fixing or
>> improving?
>>
>> Cheers,
>> Lang.
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
> Can this be changed to catch cases like this:
>
> void foo();
> if (&foo) {}
>
> Also, have you thought about formatting the diagnostic to use the
> DiagnoseImpCast() helper functions like the other implicit cast warnings?
>  If you don't use it, it would be nice to add E->getSourceRange() to
> underline the function name.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111201/409c3c7a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: func-as-bool-warning-2.patch
Type: application/octet-stream
Size: 8874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111201/409c3c7a/attachment.obj>


More information about the cfe-commits mailing list