This is the mail archive of the gcc-bugs@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]

[Bug c++/64767] Could GCC warn when a pointer is compared against '\0'?


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64767

--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Wed Jan  4 21:47:04 2017
New Revision: 244076

URL: https://gcc.gnu.org/viewcvs?rev=244076&root=gcc&view=rev
Log:
        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.

Added:
    trunk/gcc/testsuite/c-c++-common/Wpointer-compare-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c.opt
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-parser.c
    trunk/gcc/c/c-typeck.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog

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