Hi,

just found that sc_useless_cpp_parens doesn't catch #elif and doesn't catch
tabulator indentation (which I use here and there).

I attached a def.txt where the patched versions detects each line, the
original one misses a few.

Please feel free to amend the commit message regarding your preferences.

Regards, Tim
From 7be20f912b443031bf6a92d26e1fcff40189b0a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim Rühsen?= <tim.rueh...@gmx.de>
Date: Sat, 29 Apr 2017 22:50:50 +0200
Subject: [PATCH] * top/maint.mk: Improve sc_useless_cpp_parens

Also find useles parens in #elif and even when
tabs are used instead of spaces for indentation (before
and after #).
---
 top/maint.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/top/maint.mk b/top/maint.mk
index 0cabd2f31..356c66c82 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -775,7 +775,7 @@ sc_unmarked_diagnostics:
 # Avoid useless parentheses like those in this example:
 # #if defined (SYMBOL) || defined (SYM2)
 sc_useless_cpp_parens:
-	@prohibit='^# *if .*defined *\('				\
+	@prohibit='^[ $(printf "\t")]*#[ $(printf "\t")]*(if|elif) .*defined *\(' \
 	halt='found useless parentheses in cpp directive'		\
 	  $(_sc_search_regexp)

--
2.11.0

#if defined(bla)
#elif defined(blu)
# if defined(bla)
# elif defined(blu)
#  if defined(bla)
#  elif defined(blu)
#       if defined(bla)
#       elif defined(blu)
  #if defined(bla)
  #elif defined(blu)
        #if defined(bla)
        #elif defined(blu)
        #       if defined(bla)
        #       elif defined(blu)

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to