On 11/18/2015 05:16 PM, Marek Polacek wrote:
Actually, no, I think we should do this instead.

+++ gcc/c-family/c-common.c
@@ -1924,7 +1924,7 @@ warn_tautological_cmp (location_t loc, enum tree_code 
code, tree lhs, tree rhs)

    /* We do not warn for constants because they are typical of macro
       expansions that test for features, sizeof, and similar.  */
-  if (CONSTANT_CLASS_P (fold (lhs)) || CONSTANT_CLASS_P (fold (rhs)))
+  if (CONSTANT_CLASS_P (lhs) || CONSTANT_CLASS_P (rhs))
      return;

    /* Don't warn for e.g.
diff --git gcc/cp/call.c gcc/cp/call.c
index 8cdda62..77c2936 100644
--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -5741,7 +5741,7 @@ build_new_op_1 (location_t loc, enum tree_code code, int 
flags, tree arg1,
        maybe_warn_bool_compare (loc, code, fold (arg1),
                                 fold (arg2));
        if (complain & tf_warning && warn_tautological_compare)
-       warn_tautological_cmp (loc, code, arg1, arg2);
+       warn_tautological_cmp (loc, code, fold (arg1), fold (arg2));
        /* Fall through.  */
      case PLUS_EXPR:
      case MINUS_EXPR:

That seems to change the behaviour of the code though. Most of the code in warn_tautological_cmp only looks at the unfolded form. Are you sure this is safe, for example wrt. the from_macro_expansion_at tests or the CONVERT_EXPR_P ones?


Bernd

Reply via email to