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: [C/C++ PATCH] Implement -Wtautological-compare (PR c++/66555, c/54979)


Marek Polacek <polacek@redhat.com> writes:
> +  /* Don't warn for e.g.
> +     HOST_WIDE_INT n;
> +     ...
> +     if (n == (long) n) ...
> +   */
> +  if ((CONVERT_EXPR_P (lhs) || TREE_CODE (lhs) == NON_LVALUE_EXPR)
> +      ^ (CONVERT_EXPR_P (rhs) || TREE_CODE (rhs) == NON_LVALUE_EXPR))
> +    return;

I might be misreading it, sorry, but it looks like the XOR means that
we'd still warn for:

  if ((HOST_WIDE_INT) n == (long) n) ...

in cases where HOST_WIDE_INT and long have the same precision.

Thanks,
Richard


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