misra.py: Improved 'isBoolExpression'

This commit is contained in:
Daniel Marjamäki 2018-04-18 16:20:54 +02:00
parent 26e36a1d6b
commit fb89c987b0
2 changed files with 9 additions and 2 deletions

View File

@ -214,7 +214,11 @@ def hasSideEffectsRecursive(expr):
def isBoolExpression(expr):
return expr and expr.str in ['!', '==', '!=', '<', '<=', '>', '>=', '&&', '||', '0', '1']
if not expr:
return False
if expr.valueType and expr.valueType.type == 'bool':
return True
return expr.str in ['!', '==', '!=', '<', '<=', '>', '>=', '&&', '||', '0', '1']
def isConstantExpression(expr):

View File

@ -153,9 +153,12 @@ void misra_14_2() {
// TODO check more variants
}
void misra_14_4() {
void misra_14_4(bool b) {
if (x+4){} // 14.4
else {}
if (b) {}
else {}
}
void misra_15_1() {