This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: revive function address warning


Ben Elliston <bje@au1.ibm.com> writes:

>> Ben proposed -Walways-true and I believe he is implementing that.
>> This warning is in the same category as those we have for
>
> How's this?  Tested with a bootstrap and regression test run on
> powerpc-linux.
>
> 2005-12-09  Ben Elliston  <bje@au.ibm.com>
>
> 	* c-common.c (c_common_truthvalue_conversion): Generalise warning
> 	for addresses converted to booleans; not just function addresses.
> 	* c-typeck.c (build_binary_op): Warn for address comparisons which
> 	can never be NULL (eg. func == NULL or &var == NULL).
> 	* common.opt (Walways-true): New option.
> 	* c-opts.c (c_common_handle_option): Set it with -Wall.
> 	* doc/invoke.texi: Document it.
>
> testsuite/
> 2005-12-09  Ben Elliston  <bje@au.ibm.com>
>
> 	* gcc.dg/warn-addr-cmp.c: New test.
>
> Index: doc/invoke.texi
> ===================================================================
> --- doc/invoke.texi	(revision 108457)
> +++ doc/invoke.texi	(working copy)
> @@ -222,7 +222,7 @@
>  @item Warning Options
>  @xref{Warning Options,,Options to Request or Suppress Warnings}.
>  @gccoptlist{-fsyntax-only  -pedantic  -pedantic-errors @gol
> --w  -Wextra  -Wall  -Waggregate-return -Wno-attributes @gol
> +-w  -Wextra  -Wall  -Waggregate-return -Walways-true -Wno-attributes @gol
>  -Wc++-compat -Wcast-align  -Wcast-qual  -Wchar-subscripts  -Wcomment @gol
>  -Wconversion  -Wno-deprecated-declarations @gol
>  -Wdisabled-optimization  -Wno-div-by-zero  -Wno-endif-labels @gol
> @@ -3112,6 +3112,11 @@
>  called.  (In languages where you can return an array, this also elicits
>  a warning.)
>  
> +@item -Walways-true
> +@opindex Walways-true
> +Warn about comparisons which are always true such as testing if unsigned
> +values are greater than zero.
> +

 Should this be 'greater than or equal to'?


-- 
Thanks,
Jim

http://www.csclub.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]