Misra: Added rule 13.4

This commit is contained in:
Daniel Marjamäki 2017-04-13 19:43:06 +02:00
parent e7483e1b2a
commit cead8a62b4
2 changed files with 14 additions and 0 deletions

View File

@ -48,6 +48,10 @@ void misra_13_3() {
x = y++; // 13.3
}
void misra_13_4() {
if (x != (y = z)) {} // 13.4
}
void misra_13_5() {
if (x && (y++ < 123)){} // 13.5
}

View File

@ -254,6 +254,15 @@ def misra_13_3(data):
if countSideEffects(token) >= 2:
reportError(token, 13, 3)
def misra_13_4(data):
for token in data.tokenlist:
if token.str != '=':
continue
if not token.astParent:
continue
if not (token.astParent.str in [',', ';']):
reportError(token, 13, 4)
def misra_13_5(data):
for token in data.tokenlist:
if token.isLogicalOp and hasSideEffectsRecursive(token.astOperand2):
@ -297,6 +306,7 @@ for arg in sys.argv[1:]:
misra_12_4(cfg)
misra_13_1(cfg)
misra_13_3(cfg)
misra_13_4(cfg)
misra_13_5(cfg)
misra_14_4(cfg)
misra_15_1(cfg)