From df2c8f3a6577f9bc71ea05f8839c1c9a21065e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 13 Mar 2022 13:15:38 +0100 Subject: [PATCH] Fixed #10862 (Misplaced warning: misra-2.2: macros) --- addons/misra.py | 2 ++ addons/test/misra/misra-test.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/addons/misra.py b/addons/misra.py index 89d4351ec..94c21727b 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -1465,6 +1465,8 @@ class MisraChecker: def misra_2_2(self, cfg): for token in cfg.tokenlist: + if token.isExpandedMacro: + continue if (token.str in '+-') and token.astOperand2: if simpleMatch(token.astOperand1, '0'): self.reportError(token.astOperand1, 2, 2) diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 980692d5d..e6a819b9c 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -65,6 +65,8 @@ static _Noreturn void misra_1_4_func(void) // 1.4 printf_s("hello"); // 1.4 } +#define MISRA_2_2 (1*60) + static void misra_2_2(int x) { int a; a = x + 0; // 2.2 @@ -73,6 +75,7 @@ static void misra_2_2(int x) { a = 0 * x; // 2.2 a = x * 1; // 2.2 a = 1 * x; // 2.2 + a = MISRA_2_2; (void)a; }