Modified rule 11.4 (#1252)

* Modified rule 11.4

* Made changes in isEnum()

* Made suggested changes in isEnum()
This commit is contained in:
Swasti Shrivastava 2018-05-22 12:37:48 +05:30 committed by Daniel Marjamäki
parent 8320be203d
commit c511b3de20
3 changed files with 12 additions and 2 deletions

View File

@ -81,6 +81,10 @@ class ValueType:
def isFloat(self): def isFloat(self):
return self.type in {'float', 'double', 'long double'} return self.type in {'float', 'double', 'long double'}
def isEnum(self):
return self.typeScope and self.typeScope.type == "Enum"
class Token: class Token:
""" """

View File

@ -787,7 +787,9 @@ def misra_11_4(data):
vt2 = token.astOperand1.valueType vt2 = token.astOperand1.valueType
if not vt1 or not vt2: if not vt1 or not vt2:
continue 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) reportError(token, 11, 4)

View File

@ -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) { void misra_10_6(u8 x) {
@ -172,6 +172,10 @@ void misra_11_3(u8* p) {
void misra_11_4(u8*p) { void misra_11_4(u8*p) {
u64 y = (u64)p; // 11.4 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) { void misra_11_5(void *p) {