re PR c++/64767 (Could GCC warn when a pointer is compared against '\0'?)
authorMarek Polacek <polacek@redhat.com>
Wed, 4 Jan 2017 21:47:04 +0000 (21:47 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 4 Jan 2017 21:47:04 +0000 (21:47 +0000)
commita9342885b149d3dd47037c937c012ba76580acd5
treed230c083213bb30f68b85cc5cdcb389fbfc76650
parentabec4284a64b3ebc6f986b5223a3623e682ae348
re PR c++/64767 (Could GCC warn when a pointer is compared against '\0'?)

PR c++/64767
* c.opt (Wpointer-compare): New option.

* c-parser.c (c_parser_postfix_expression): Mark zero character
constants by setting original_type in c_expr.
* c-typeck.c (parser_build_binary_op): Warn when a pointer is compared
with a zero character constant.
(char_type_p): New function.

* typeck.c (cp_build_binary_op): Warn when a pointer is compared with
a zero character literal.

* doc/invoke.texi: Document -Wpointer-compare.

* c-c++-common/Wpointer-compare-1.c: New test.

From-SVN: r244076
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wpointer-compare-1.c [new file with mode: 0644]