diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py index 30a65ed69..2ffbd6e9f 100755 --- a/addons/cppcheckdata.py +++ b/addons/cppcheckdata.py @@ -81,6 +81,10 @@ class ValueType: def isFloat(self): return self.type in {'float', 'double', 'long double'} + def isEnum(self): + return self.typeScope and self.typeScope.type == "Enum" + + class Token: """ diff --git a/addons/misra.py b/addons/misra.py index c31338910..93f062155 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -787,7 +787,9 @@ def misra_11_4(data): vt2 = token.astOperand1.valueType if not vt1 or not vt2: continue - if vt1.pointer == 0 and vt2.pointer > 0 and vt2.type != 'void': + if vt2.pointer > 0 and vt1.pointer == 0 and (vt1.isIntegral() or vt1.isEnum()) and vt2.type != 'void': + reportError(token, 11, 4) + elif vt1.pointer > 0 and vt2.pointer == 0 and (vt2.isIntegral() or vt2.isEnum())and vt1.type != 'void': reportError(token, 11, 4) diff --git a/addons/test/misra-test.c b/addons/test/misra-test.c index 7a76e5629..72db1c314 100644 --- a/addons/test/misra-test.c +++ b/addons/test/misra-test.c @@ -154,7 +154,7 @@ void misra_10_4(u32 x, s32 y) { { ; } - z = x + y //10.4 + z = x + y; //10.4 } void misra_10_6(u8 x) { @@ -172,6 +172,10 @@ void misra_11_3(u8* p) { void misra_11_4(u8*p) { u64 y = (u64)p; // 11.4 + u8 *misra_11_4_A = ( u8 * ) 0x0005;// 11.4 + s32 misra_11_4_B; + u8 *q = ( u8 * ) misra_11_4_B; // 11.4 + } void misra_11_5(void *p) {