Misra: Added rule 16.7

This commit is contained in:
Daniel Marjamäki 2017-04-14 13:23:53 +02:00
parent 47126e93a4
commit e5286c61d5
2 changed files with 14 additions and 1 deletions

View File

@ -164,4 +164,11 @@ void misra_16_6() {
}
}
void misra_16_7() {
switch (x != 123) { // 16.7
case 1:
break;
default:
break;
}
}

View File

@ -492,6 +492,11 @@ def misra_16_6(data):
if count < 2:
reportError(token, 16, 6)
def misra_16_7(data):
for token in data.tokenlist:
if simpleMatch(token, 'switch (') and isBoolExpression(token.next.astOperand2):
reportError(token, 16, 7)
if '-verify' in sys.argv[1:]:
VERIFY = True
@ -550,6 +555,7 @@ for arg in sys.argv[1:]:
misra_16_4(cfg)
misra_16_5(cfg)
misra_16_6(cfg)
misra_16_7(cfg)
if VERIFY:
for expected in VERIFY_EXPECTED: