Fixed #8656 (false positive: MISRA rule 10.1)

This commit is contained in:
Daniel Marjamäki 2019-08-11 09:47:37 +02:00
parent 8c7ae14f0b
commit 43aabcd318
2 changed files with 10 additions and 1 deletions

View File

@ -98,6 +98,14 @@ def getEssentialTypeCategory(expr):
return None
if expr.valueType and expr.valueType.typeScope:
return "enum<" + expr.valueType.typeScope.className + ">"
if expr.astOperand1 and expr.astOperand2:
e1 = getEssentialTypeCategory(expr.astOperand1)
e2 = getEssentialTypeCategory(expr.astOperand2)
#print('{0}: {1} {2}'.format(expr.str, e1, e2))
if e1 and e2 and e1 == e2:
return e1
if expr.valueType:
return expr.valueType.sign
if expr.variable:
typeToken = expr.variable.typeStartToken
while typeToken:

View File

@ -161,9 +161,10 @@ void misra_9_5() {
int x[] = {[0]=23}; // 9.5
}
void misra_10_1() {
void misra_10_1(uint8_t u) {
int32_t i;
i = 3 << 1; // 10.1
i = (u & u) << 4; // no-warning
}
void misra_10_4(u32 x, s32 y) {