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(+)

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,
-- 
1.8.5.3

Reply via email to