diff --git a/addons/misra.py b/addons/misra.py index 9f75874d2..2a79f40d4 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -802,6 +802,15 @@ def misra_11_4(data): def misra_11_5(data): for token in data.tokenlist: if not isCast(token): + if token.str == "=" and token.next.str != "(": + vt1 = token.astOperand1.valueType + vt2 = token.astOperand2.valueType + if not vt1 or not vt2: + continue + if vt1.pointer > 0 and vt1.type != 'void' and vt2.pointer == vt1.pointer and vt2.type == 'void': + reportError(token, 11, 5) + continue + if token.astOperand1.astOperand1 and token.astOperand1.astOperand1.str in {'malloc', 'calloc', 'realloc', 'free'}: continue vt1 = token.valueType vt2 = token.astOperand1.valueType diff --git a/addons/test/misra-test.c b/addons/test/misra-test.c index 9b4fd2d85..3f56a78c1 100644 --- a/addons/test/misra-test.c +++ b/addons/test/misra-test.c @@ -179,7 +179,9 @@ void misra_11_4(u8*p) { } void misra_11_5(void *p) { + u16 *p16; x = (u8 *)p; // 11.5 + p16 = p; //11.5 } void misra_11_6() {