diff --git a/addons/misra.py b/addons/misra.py index 673d29303..0e8a24185 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -98,6 +98,14 @@ def getEssentialTypeCategory(expr): return None if expr.valueType and expr.valueType.typeScope: return "enum<" + expr.valueType.typeScope.className + ">" + if expr.astOperand1 and expr.astOperand2: + e1 = getEssentialTypeCategory(expr.astOperand1) + e2 = getEssentialTypeCategory(expr.astOperand2) + #print('{0}: {1} {2}'.format(expr.str, e1, e2)) + if e1 and e2 and e1 == e2: + return e1 + if expr.valueType: + return expr.valueType.sign if expr.variable: typeToken = expr.variable.typeStartToken while typeToken: diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 7be4b21c2..72f0ae110 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -161,9 +161,10 @@ void misra_9_5() { int x[] = {[0]=23}; // 9.5 } -void misra_10_1() { +void misra_10_1(uint8_t u) { int32_t i; i = 3 << 1; // 10.1 + i = (u & u) << 4; // no-warning } void misra_10_4(u32 x, s32 y) {