c-family PATCH for warn_logical_operator

Message ID 20171218103505.GI2605@redhat.com
State New
Headers show
Series
  • c-family PATCH for warn_logical_operator
Related show

Commit Message

Marek Polacek Dec. 18, 2017, 10:35 a.m.
While looking into something else I noticed that because of the missing
warn_logical_op check we do unnecessary work in warn_logical_operator, like
calling fold_for_warn which can put stuff into cv/fold_cache etc.  It also
causes more noise when debugging.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2017-12-18  Marek Polacek  <polacek@redhat.com>

	* c-warn.c (warn_logical_operator): Return early if -Wlogical-op is
	not in effect.


	Marek

Comments

Jeff Law Dec. 18, 2017, 4:28 p.m. | #1
On 12/18/2017 03:35 AM, Marek Polacek wrote:
> While looking into something else I noticed that because of the missing

> warn_logical_op check we do unnecessary work in warn_logical_operator, like

> calling fold_for_warn which can put stuff into cv/fold_cache etc.  It also

> causes more noise when debugging.

> 

> Bootstrapped/regtested on x86_64-linux, ok for trunk?

> 

> 2017-12-18  Marek Polacek  <polacek@redhat.com>

> 

> 	* c-warn.c (warn_logical_operator): Return early if -Wlogical-op is

> 	not in effect.

OK.
jeff

Patch

--- gcc/c-family/c-warn.c
+++ gcc/c-family/c-warn.c
@@ -180,6 +180,9 @@  warn_logical_operator (location_t location, enum tree_code code, tree type,
   tree low0, low1, low, high0, high1, high, lhs, rhs, tem;
   bool strict_overflow_p = false;
 
+  if (!warn_logical_op)
+    return;
+
   if (code != TRUTH_ANDIF_EXPR
       && code != TRUTH_AND_EXPR
       && code != TRUTH_ORIF_EXPR