From 8c42e052ac40f3033904753709b6c97b6eae031b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 14 Apr 2017 20:51:09 +0200 Subject: [PATCH] Misra: Added rule 18.5 --- addons/misra-test.c | 4 ++++ addons/misra.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/addons/misra-test.c b/addons/misra-test.c index 054878193..7e16adcde 100644 --- a/addons/misra-test.c +++ b/addons/misra-test.c @@ -180,3 +180,7 @@ void misra_17_6(int x[static 20]) {} // 17.6 void misra_17_8(int x) { x = 3; // 17.8 } + +void misra_18_5() { + int *** p; // 18.5 +} diff --git a/addons/misra.py b/addons/misra.py index 435a6b74c..369769ba0 100644 --- a/addons/misra.py +++ b/addons/misra.py @@ -517,6 +517,22 @@ def misra_17_8(data): if var and var.isArgument: reportError(token, 17, 8) +def misra_18_5(data): + for var in data.variables: + if not var.isPointer: + continue + typetok = var.nameToken + count = 0 + while typetok: + if typetok.str == '*': + count = count + 1 + elif not typetok.isName: + break + typetok = typetok.previous + if count > 2: + reportError(var.nameToken, 18, 5) + + if '-verify' in sys.argv[1:]: VERIFY = True @@ -579,6 +595,7 @@ for arg in sys.argv[1:]: misra_17_1(data.rawTokens) misra_17_6(data.rawTokens) misra_17_8(cfg) + misra_18_5(cfg) if VERIFY: for expected in VERIFY_EXPECTED: