Misra: Added rule 17.8

This commit is contained in:
Daniel Marjamäki 2017-04-14 20:38:35 +02:00
parent f45a5ed29e
commit e8af55e890
2 changed files with 15 additions and 0 deletions

View File

@ -176,3 +176,7 @@ void misra_16_7() {
}
void misra_17_6(int x[static 20]) {} // 17.6
void misra_17_8(int x) {
x = 3; // 17.8
}

View File

@ -507,6 +507,16 @@ def misra_17_6(rawTokens):
if simpleMatch(token, '[ static'):
reportError(token, 17, 6)
def misra_17_8(data):
for token in data.tokenlist:
if not (token.isAssignmentOp or (token.str in ['++','--'])):
continue
if not token.astOperand1:
continue
var = token.astOperand1.variable
if var and var.isArgument:
reportError(token, 17, 8)
if '-verify' in sys.argv[1:]:
VERIFY = True
@ -568,6 +578,7 @@ for arg in sys.argv[1:]:
if cfgNumber == 1:
misra_17_1(data.rawTokens)
misra_17_6(data.rawTokens)
misra_17_8(cfg)
if VERIFY:
for expected in VERIFY_EXPECTED: