diff --git a/addons/misra-test.c b/addons/misra-test.c index 143038188..3c35592cd 100644 --- a/addons/misra-test.c +++ b/addons/misra-test.c @@ -169,6 +169,9 @@ int misra_15_5() { void misra_15_6() { if (x!=0); // 15.6 else{} +#if A + (void)0; +#endif } void misra_15_7() { diff --git a/addons/misra.py b/addons/misra.py index fd7199cba..6853db599 100644 --- a/addons/misra.py +++ b/addons/misra.py @@ -638,11 +638,18 @@ def misra_15_5(data): def misra_15_6(rawTokens): state = 0 indent = 0 + tok1 = None for token in rawTokens: if token.str in ['if', 'for', 'while']: + if token.previous and token.previous.str == '#': + continue state = 1 indent = 0 + tok1 = token elif state == 1: + if indent == 0 and token.str != '(': + state = 0 + continue if token.str == '(': indent = indent + 1 elif token.str == ')': @@ -656,7 +663,7 @@ def misra_15_6(rawTokens): continue state = 0 if token.str != '{': - reportError(token, 15, 6) + reportError(tok1, 15, 6) def misra_15_7(data): for token in data.tokenlist: