parent
9bf604c46c
commit
742d6513a1
|
@ -170,7 +170,11 @@ def getEssentialType(expr):
|
||||||
return typeToken.str
|
return typeToken.str
|
||||||
typeToken = typeToken.next
|
typeToken = typeToken.next
|
||||||
|
|
||||||
elif expr.astOperand1 and expr.astOperand2 and expr.str in {'+', '-', '*', '/', '%', '&', '|', '^'}:
|
elif expr.astOperand1 and expr.astOperand2 and expr.str in {'+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":"}:
|
||||||
|
if expr.astOperand1.valueType and expr.astOperand1.valueType.pointer > 0:
|
||||||
|
return None
|
||||||
|
if expr.astOperand2.valueType and expr.astOperand2.valueType.pointer > 0:
|
||||||
|
return None
|
||||||
e1 = getEssentialType(expr.astOperand1)
|
e1 = getEssentialType(expr.astOperand1)
|
||||||
e2 = getEssentialType(expr.astOperand2)
|
e2 = getEssentialType(expr.astOperand2)
|
||||||
if not e1 or not e2:
|
if not e1 or not e2:
|
||||||
|
@ -184,6 +188,9 @@ def getEssentialType(expr):
|
||||||
return types[i1]
|
return types[i1]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
elif expr.str == "~":
|
||||||
|
e1 = getEssentialType(expr.astOperand1)
|
||||||
|
return e1
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -767,6 +774,9 @@ def misra_10_6(data):
|
||||||
for token in data.tokenlist:
|
for token in data.tokenlist:
|
||||||
if token.str != '=' or not token.astOperand1 or not token.astOperand2:
|
if token.str != '=' or not token.astOperand1 or not token.astOperand2:
|
||||||
continue
|
continue
|
||||||
|
if (token.astOperand2.str not in {'+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":", '~'} and
|
||||||
|
not isCast(token.astOperand2)):
|
||||||
|
continue
|
||||||
vt1 = token.astOperand1.valueType
|
vt1 = token.astOperand1.valueType
|
||||||
vt2 = token.astOperand2.valueType
|
vt2 = token.astOperand2.valueType
|
||||||
if not vt1 or vt1.pointer > 0:
|
if not vt1 or vt1.pointer > 0:
|
||||||
|
@ -776,7 +786,10 @@ def misra_10_6(data):
|
||||||
try:
|
try:
|
||||||
intTypes = ['char', 'short', 'int', 'long', 'long long']
|
intTypes = ['char', 'short', 'int', 'long', 'long long']
|
||||||
index1 = intTypes.index(vt1.type)
|
index1 = intTypes.index(vt1.type)
|
||||||
e = getEssentialType(token.astOperand2)
|
if isCast(token.astOperand2):
|
||||||
|
e = vt2.type
|
||||||
|
else:
|
||||||
|
e = getEssentialType(token.astOperand2)
|
||||||
if not e:
|
if not e:
|
||||||
continue
|
continue
|
||||||
index2 = intTypes.index(e)
|
index2 = intTypes.index(e)
|
||||||
|
@ -785,7 +798,6 @@ def misra_10_6(data):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def misra_10_8(data):
|
def misra_10_8(data):
|
||||||
for token in data.tokenlist:
|
for token in data.tokenlist:
|
||||||
if not isCast(token):
|
if not isCast(token):
|
||||||
|
|
|
@ -162,8 +162,10 @@ 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, u32 a, u32 b) {
|
||||||
u16 y = x+x; // 10.6
|
u16 y = x+x; // 10.6
|
||||||
|
u16 z = ~u8 x ;//10.6
|
||||||
|
u32 c = ( u16) ( u32 a + u32 b ); //10.6
|
||||||
}
|
}
|
||||||
|
|
||||||
void misra_10_8(u8 x) {
|
void misra_10_8(u8 x) {
|
||||||
|
|
Loading…
Reference in New Issue