From 753bc321f09f0409d4b5dc29d9dcc67728fdcead Mon Sep 17 00:00:00 2001 From: Johan Eriksson Date: Mon, 9 Feb 2026 10:19:38 +0100 Subject: [PATCH] Enhance directive handling for #if and #elif --- addons/misra.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/misra.py b/addons/misra.py index cea5596d47d..18a32409717 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3891,10 +3891,10 @@ def misra_20_14(self, data): # the size increases when there are inner #if directives. ifStack = [] for directive in data.directives: - if directive.str.startswith('#if ') or directive.str.startswith('#ifdef ') or directive.str.startswith( - '#ifndef '): + if directive.str.startswith('#if ') or directive.str.startswith('#if(') or directive.str.startswith('#ifdef ') + or directive.str.startswith('#ifndef '): ifStack.append(directive) - elif directive.str == '#else' or directive.str.startswith('#elif '): + elif directive.str == '#else' or directive.str.startswith('#elif ') or directive.str.startswith('#elif('): if len(ifStack) == 0: self.reportError(directive, 20, 14) ifStack.append(directive)