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,17 +808,31 @@ def misra_10_8(data):
|
|||
continue
|
||||
if not token.astOperand1.astOperand1:
|
||||
continue
|
||||
try:
|
||||
intTypes = ['char', 'short', 'int', 'long', 'long long']
|
||||
index1 = intTypes.index(token.valueType.type)
|
||||
e = getEssentialType(token.astOperand1)
|
||||
if not e:
|
||||
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
|
||||
index2 = intTypes.index(e)
|
||||
if index1 > index2:
|
||||
reportError(token, 10, 8)
|
||||
except ValueError:
|
||||
pass
|
||||
e1 = getEssentialTypeCategory(token)
|
||||
if e1 != e2:
|
||||
reportError(token, 10, 8)
|
||||
else:
|
||||
try:
|
||||
intTypes = ['char', 'short', 'int', 'long', 'long long']
|
||||
index1 = intTypes.index(token.valueType.type)
|
||||
e = getEssentialType(token.astOperand1)
|
||||
if not e:
|
||||
continue
|
||||
index2 = intTypes.index(e)
|
||||
if index1 > index2:
|
||||
reportError(token, 10, 8)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
||||
def misra_11_3(data):
|
||||
|
|
|
@ -168,9 +168,10 @@ void misra_10_6(u8 x, u32 a, u32 b) {
|
|||
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+x); // 10.8
|
||||
y = (u16) (a + b) //10.8
|
||||
}
|
||||
|
||||
struct Fred {}; struct Wilma {};
|
||||
|
|
Loading…
Reference in New Issue