On 09/20/2016 01:13 PM, Marek Polacek wrote:
On Mon, Sep 19, 2016 at 02:41:04PM -0400, Jason Merrill wrote:
On 09/16/2016 05:01 AM, Marek Polacek wrote:
@@ -5853,7 +5853,16 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool 
noconvert,
                                                   arg, true)))
        errstring = _("wrong type argument to bit-complement");
       else if (!noconvert && CP_INTEGRAL_TYPE_P (TREE_TYPE (arg)))
-       arg = cp_perform_integral_promotions (arg, complain);
+       {
+         /* Warn if the expression has boolean value.  */
+         location_t location = EXPR_LOC_OR_LOC (arg, input_location);

Let's move this variable to the beginning of the function; hopefully it will
become a parameter soon.

Done.

+         if ((TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE
+              || truth_value_p (TREE_CODE (arg)))

You shouldn't need to check truth_value_p; in C++ all truth operations have
type bool.

Oops, force of habit...

+             && warning_at (location, OPT_Wbool_operation,
+                            "%<~%> on a boolean expression"))

And let's refer to "expression of type bool" rather than "boolean
expression".

Adjusted (and in the C FE too).

Hmm, I'm not sure that change is right for C.  But the C++ hunk is OK.

Jason

Reply via email to