On 09/15/2016 05:19 AM, Bernd Edlinger wrote:
+      if (warn_int_in_bool_context)
+       {
+         tree val1 = fold_for_warn (TREE_OPERAND (expr, 1));
+         tree val2 = fold_for_warn (TREE_OPERAND (expr, 2));
+         if (TREE_CODE (val1) == INTEGER_CST
+             && TREE_CODE (val2) == INTEGER_CST
+             && !integer_zerop (val1)
+             && !integer_zerop (val2)
+             && (!integer_onep (val1)
+                 || !integer_onep (val2)))
+           warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
+                       "?: using integer constants in boolean context");


I think this message could be more helpful; we're warning about code that always evaluates to 'true', so we could say something like "conditional expression always evaluates to true". In which case maybe your original warning name was better.

I'm also not sure we need to check integer_onep at all before giving that warning. Were you seeing a lot of false positives without that check?

Jason

Reply via email to