Fixed #9506 (false positive: MISRA 12.4)
This commit is contained in:
parent
f5df06a143
commit
55afaebdac
|
@ -345,14 +345,7 @@ def isConstantExpression(expr):
|
|||
|
||||
|
||||
def isUnsignedInt(expr):
|
||||
# TODO this function is very incomplete. use ValueType?
|
||||
if not expr:
|
||||
return False
|
||||
if expr.isNumber:
|
||||
return 'u' in expr.str or 'U' in expr.str
|
||||
if expr.str in ('+', '-', '*', '/', '%'):
|
||||
return isUnsignedInt(expr.astOperand1) or isUnsignedInt(expr.astOperand2)
|
||||
return False
|
||||
return expr and expr.valueType and expr.valueType.type in ('short', 'int') and expr.valueType.sign == 'unsigned'
|
||||
|
||||
|
||||
def getPrecedence(expr):
|
||||
|
@ -1370,8 +1363,6 @@ class MisraChecker:
|
|||
continue
|
||||
if (not isConstantExpression(token)) or (not isUnsignedInt(token)):
|
||||
continue
|
||||
if not token.values:
|
||||
continue
|
||||
for value in token.values:
|
||||
if value.intvalue < 0 or value.intvalue > max_uint:
|
||||
self.reportError(token, 12, 4)
|
||||
|
|
|
@ -367,6 +367,7 @@ void misra_12_4() {
|
|||
x = MISRA12_4a + MISRA12_4b; // 12.4
|
||||
x = 0u - 1u; // 12.4
|
||||
x = t ? 0u : (0u-1u); // 12.4
|
||||
x = 556200230913ULL;
|
||||
}
|
||||
|
||||
struct misra_13_1_t { int a; int b; };
|
||||
|
|
Loading…
Reference in New Issue