From a47a5e55e436ab6c4a4d548a07b75bbc9b41ac24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 17 Apr 2017 09:38:46 +0200 Subject: [PATCH] Misra: Fix FP, rule 15.6 --- addons/misra-test.c | 3 +++ addons/misra.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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: