diff mbox

Extend -Wint-in-bool-context to warn for multiplications

Message ID AM4PR0701MB2162BF5814EC93A55A678511E4D70@AM4PR0701MB2162.eurprd07.prod.outlook.com
State New
Headers show

Commit Message

Bernd Edlinger Oct. 22, 2016, 6:52 a.m. UTC
On 10/22/16 04:17, Martin Sebor wrote:
> On 10/21/2016 04:37 PM, Joseph Myers wrote:
>> The quoting in the diagnostic should be %<&&%>, not '&&'.
>
> Presumably same for '*' (i.e., %<*%>).
>
> But I would actually suggest a somewhat more formal phrasing than
> "better use xxx here" such as "suggest %<&&%> instead" or something
> akin to what's already in place elsewhere in gcc.pot.
>

Aehm, yes.  That would be better then:




I assume then I should adjust the warning a few lines below as well:

         warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
                     "<< in boolean context, did you mean '<' ?");



Bernd.
diff mbox

Patch

Index: c-common.c
===================================================================
--- c-common.c	(revision 241400)
+++ c-common.c	(working copy)
@@ -3327,6 +3327,11 @@ 
  	return c_common_truthvalue_conversion (location,
  					       TREE_OPERAND (expr, 0));

+    case MULT_EXPR:
+      warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
+		  "%<*%> in boolean context, suggest %<&&%> instead");
+      break;
+
      case LSHIFT_EXPR:
        /* We will only warn on signed shifts here, because the majority of
  	 false positive warnings happen in code where unsigned arithmetic