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: [Bug c/7776] const char* p = "foo"; if (p == "foo") ... is compiled without warning!


    --- fold-const.c        23 May 2003 03:46:52 -0000      1.252
    +++ fold-const.c        25 May 2003 00:56:19 -0000
 
    +      /* Warn about things like if (str == "foo").  */
    +      if ((code == EQ_EXPR || code == NE_EXPR)
    +         && TREE_CODE (arg1) == ADDR_EXPR
    +         && TREE_CODE (TREE_OPERAND (arg1, 0)) == STRING_CST)
    +       warning("comparison with string literal");
    +

Warning of this nature should be done when the tree is built, not when
its folded.  Also, there needs to a blank after "warning".


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