diff --git a/addons/misra.py b/addons/misra.py index 62a87666490..7482e949d92 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -430,11 +430,11 @@ def is_composite_expr(expr, composite_operator=False): return False if not composite_operator: - if (expr.str in ('+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":", '~')): - return is_composite_expr(expr.astOperand1,True) or is_composite_expr(expr.astOperand2, True) if expr.str == '?' and simpleMatch(expr.astOperand2, ':'): colon = expr.astOperand2 return is_composite_expr(colon.astOperand1,True) or is_composite_expr(colon.astOperand2, True) + if (expr.str in ('+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":", '~')): + return is_composite_expr(expr.astOperand1,True) or is_composite_expr(expr.astOperand2, True) return False # non constant expression? diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index fc0abdab7ca..d36ad6c25d4 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -769,6 +769,7 @@ struct misra_10_6_s { static void misra_10_6(u8 x, char c1, char c2) { u16 y1 = x+x; // 10.6 u16 y2 = (0x100u - 0x80u); // rhs is not a composite expression because it's a constant expression + int b = (y2 == y2) ? 0 : 1; // no-warning u16 z = ~u8 x ;//10.6 s32 i = c1 - c2; // 10.3 struct misra_10_6_s s;