Misra: Added rule 13.6

This commit is contained in:
Daniel Marjamäki 2017-04-13 21:40:59 +02:00
parent cead8a62b4
commit 0c26d9e470
2 changed files with 10 additions and 0 deletions

View File

@ -56,6 +56,10 @@ void misra_13_5() {
if (x && (y++ < 123)){} // 13.5
}
void misra_13_6() {
return sizeof(x++); // 13.6
}
void misra_14_4() {
if (x+4){} // 14.4
}

View File

@ -268,6 +268,11 @@ def misra_13_5(data):
if token.isLogicalOp and hasSideEffectsRecursive(token.astOperand2):
reportError(token, 13, 5)
def misra_13_6(data):
for token in data.tokenlist:
if token.str == 'sizeof' and hasSideEffectsRecursive(token.next):
reportError(token, 13, 6)
def misra_14_4(data):
for token in data.tokenlist:
if token.str != '(':
@ -308,5 +313,6 @@ for arg in sys.argv[1:]:
misra_13_3(cfg)
misra_13_4(cfg)
misra_13_5(cfg)
misra_13_6(cfg)
misra_14_4(cfg)
misra_15_1(cfg)