[cfe-commits] [patch] Function literal to bool conversion fixit notes
David Blaikie
dblaikie at gmail.com
Thu Dec 8 19:43:10 PST 2011
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.
I updated the test cases, added a couple, though in the interests of
reducing noise I just -Wno-bool-conversions on one of the unrelated test
files that happened to trigger this warning alot.
Oh, one other question - the quoting of 'true' in this warning is
inconsistent with another warning I saw "self-comparison always evaluates
to false" - which do you think we should prefer/use?
Thanks,
- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111208/d414e7a5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: function-to-bool-notes.diff
Type: text/x-diff
Size: 11094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111208/d414e7a5/attachment.diff>
More information about the cfe-commits
mailing list