From e8af55e8901cbed978a9346926b1ec8dfc8f8dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 14 Apr 2017 20:38:35 +0200 Subject: [PATCH] Misra: Added rule 17.8 --- addons/misra-test.c | 4 ++++ addons/misra.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/addons/misra-test.c b/addons/misra-test.c index 8aa874949..054878193 100644 --- a/addons/misra-test.c +++ b/addons/misra-test.c @@ -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 +} diff --git a/addons/misra.py b/addons/misra.py index 7e50d2246..435a6b74c 100644 --- a/addons/misra.py +++ b/addons/misra.py @@ -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: