diff mbox

Avoid unnecessary work when -Wmisleading-indentation isn't enabled

Message ID 1431530756-26831-1-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm May 13, 2015, 3:25 p.m. UTC
This might qualify as "obvious".

OK for trunk?  (if it passes bootstrap and regrtest)

gcc/c-family/ChangeLog:
	* c-indentation.c (warn_for_misleading_indentation): Bail out
	immediately if -Wmisleading-indentation isn't enabled.
---
 gcc/c-family/c-indentation.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Marek Polacek May 13, 2015, 3:16 p.m. UTC | #1
On Wed, May 13, 2015 at 11:25:56AM -0400, David Malcolm wrote:
> This might qualify as "obvious".
> 
> OK for trunk?  (if it passes bootstrap and regrtest)

Ok.

	Marek
diff mbox

Patch

diff --git a/gcc/c-family/c-indentation.c b/gcc/c-family/c-indentation.c
index 94565f6..9aeebae 100644
--- a/gcc/c-family/c-indentation.c
+++ b/gcc/c-family/c-indentation.c
@@ -373,6 +373,12 @@  warn_for_misleading_indentation (location_t guard_loc,
 				 enum cpp_ttype next_tok_type,
 				 const char *guard_kind)
 {
+  /* Early reject for the case where -Wmisleading-indentation is disabled,
+     to avoid doing work only to have the warning suppressed inside the
+     diagnostic machinery.  */
+  if (!warn_misleading_indentation)
+    return;
+
   if (should_warn_for_misleading_indentation (guard_loc,
 					      body_loc,
 					      next_stmt_loc,