Fixed #10862 (Misplaced warning: misra-2.2: macros)

This commit is contained in:
Daniel Marjamäki 2022-03-13 13:15:38 +01:00
parent 190506db40
commit df2c8f3a65
2 changed files with 5 additions and 0 deletions

View File

@ -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)

View File

@ -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;
}