misra: fix misra-10.7 false positive for constant expression

This commit is contained in:
Daniel Marjamäki 2023-01-02 18:52:33 +01:00
parent 2007cd0a1d
commit 5830047fcb
2 changed files with 4 additions and 0 deletions

View File

@ -2302,6 +2302,8 @@ class MisraChecker:
continue continue
if not token.isArithmeticalOp: if not token.isArithmeticalOp:
continue continue
if not is_composite_expr(token):
continue
parent = token.astParent parent = token.astParent
if parent is None: if parent is None:
continue continue

View File

@ -736,6 +736,7 @@ static void misra_10_6_1(uint32_t *a, uint16_t b, uint16_t c)
*a = b + c ; // 10.6 *a = b + c ; // 10.6
} }
static void misra_10_7_f1(struct Timer *pSelf, uint32_t interval_ms);
static void misra_10_7(uint16_t u16a, uint16_t u16b) { static void misra_10_7(uint16_t u16a, uint16_t u16b) {
uint32_t u32a = 100u; uint32_t u32a = 100u;
res = u32a * u16a + u16b; // 12.1 no-warning res = u32a * u16a + u16b; // 12.1 no-warning
@ -744,6 +745,7 @@ static void misra_10_7(uint16_t u16a, uint16_t u16b) {
res = u32a * (u16a + u16b); // 10.7 res = u32a * (u16a + u16b); // 10.7
u32a *= u16a + u16b; // 10.7 u32a *= u16a + u16b; // 10.7
u32a = ((uint32_t)4 * (uint32_t)2 * (uint32_t)4 ); // no-warning (#10488) u32a = ((uint32_t)4 * (uint32_t)2 * (uint32_t)4 ); // no-warning (#10488)
dostuff(&t, (2*60*1000)); // no-warning
} }
static void misra_10_8(u8 x, s32 a, s32 b) { static void misra_10_8(u8 x, s32 a, s32 b) {