Modified Rule 10.8 (#1265)
* Modified Rule 10.8 * Made suggested changes to handle unary operators
This commit is contained in:
parent
c2c43ce8a7
commit
a3b9745557
|
@ -808,6 +808,20 @@ def misra_10_8(data):
|
||||||
continue
|
continue
|
||||||
if not token.astOperand1.astOperand1:
|
if not token.astOperand1.astOperand1:
|
||||||
continue
|
continue
|
||||||
|
if token.astOperand1.str not in {'+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":", '~'}:
|
||||||
|
continue
|
||||||
|
if token.astOperand1.str != '~' and not token.astOperand1.astOperand2:
|
||||||
|
continue
|
||||||
|
if token.astOperand1.str == '~':
|
||||||
|
e2 = getEssentialTypeCategory(token.astOperand1.astOperand1)
|
||||||
|
else:
|
||||||
|
e2, e3 = getEssentialCategorylist(token.astOperand1.astOperand1, token.astOperand1.astOperand2)
|
||||||
|
if e2 != e3:
|
||||||
|
continue
|
||||||
|
e1 = getEssentialTypeCategory(token)
|
||||||
|
if e1 != e2:
|
||||||
|
reportError(token, 10, 8)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
intTypes = ['char', 'short', 'int', 'long', 'long long']
|
intTypes = ['char', 'short', 'int', 'long', 'long long']
|
||||||
index1 = intTypes.index(token.valueType.type)
|
index1 = intTypes.index(token.valueType.type)
|
||||||
|
|
|
@ -168,9 +168,10 @@ void misra_10_6(u8 x, u32 a, u32 b) {
|
||||||
u32 c = ( u16) ( u32 a + u32 b ); //10.6
|
u32 c = ( u16) ( u32 a + u32 b ); //10.6
|
||||||
}
|
}
|
||||||
|
|
||||||
void misra_10_8(u8 x) {
|
void misra_10_8(u8 x, s32 a, s32 b) {
|
||||||
y = (u16)x;
|
y = (u16)x;
|
||||||
y = (u16)(x+x); // 10.8
|
y = (u16)(x+x); // 10.8
|
||||||
|
y = (u16) (a + b) //10.8
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Fred {}; struct Wilma {};
|
struct Fred {}; struct Wilma {};
|
||||||
|
|
Loading…
Reference in New Issue