Misra: Add rule 5.4

This commit is contained in:
Daniel Marjamäki 2017-04-17 12:55:19 +02:00
parent c56926f4bd
commit 11621b2b36
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -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)