From 11621b2b3679347e16bbb00d049a364be455b407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 17 Apr 2017 12:55:19 +0200 Subject: [PATCH] Misra: Add rule 5.4 --- addons/misra-test.c | 3 +++ addons/misra.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/addons/misra-test.c b/addons/misra-test.c index 332813095..cf9683f68 100644 --- a/addons/misra-test.c +++ b/addons/misra-test.c @@ -17,6 +17,9 @@ void misra_5_1() { int a1234567890123456789012345678901; // 5.1 } +#define m54_12345678901234567890123456 1 // no-warning +#define m54_1234567890123456789012345678 2 // 5.4 + #define m55(x,y) (x+y) int m55; // 5.5 diff --git a/addons/misra.py b/addons/misra.py index 2b26afda7..48187392a 100644 --- a/addons/misra.py +++ b/addons/misra.py @@ -273,6 +273,11 @@ def misra_5_1(data): if token.isName and len(token.str) > 31: reportError(token, 5, 1) +def misra_5_4(data): + for dir in data.directives: + if re.match(r'#define [a-zA-Z0-9_]{32,}', dir.str): + reportError(dir, 5, 4) + def misra_5_5(data): macroNames = [] for dir in data.directives: @@ -959,6 +964,7 @@ for arg in sys.argv[1:]: print('Checking ' + arg + ', config "' + cfg.name + '"...') misra_5_1(cfg) + misra_5_4(cfg) misra_5_5(cfg) if cfgNumber == 1: misra_7_1(data.rawTokens)