[cfe-commits] [patch] Function literal to bool conversion fixit notes

Matt Beaumont-Gay matthewbg at google.com
Thu Dec 8 20:01:13 PST 2011


On Thu, Dec 8, 2011 at 19:43, David Blaikie <dblaikie at gmail.com> wrote:
> Just adding some finishing touches to Lang's recent excursion into the front
> end by adding notes to describe how to suppress (and in simple cases, fix)
> the warning
>
> /tmp/webcompile/_7230_0.cc:3:10: warning: address of function 'f1' will
> always evaluate to 'true' [-Wbool-conversions]
>   return f1;
>          ^~
> /tmp/webcompile/_7230_0.cc:3:10: note: prefix with the address-of operator
> to silence this warning
>   return f1;
>          ^
>          &
> /tmp/webcompile/_7230_0.cc:3:10: note: suffix with parentheses to turn this
> into a function call
>   return f1;
>          ^
>            ()
>
> The latter note is only included if the function has a bool return and no
> arguments (I couldn't figure out how to account for default or variadic
> arguments - suggestions welcome. Also for bool conversion) so this is fairly
> simple.

You might be interested in Sema::isExprCallable and Sema::tryToRecoverWithCall.

-Matt



More information about the cfe-commits mailing list