Misra: Add rule 11.9

This commit is contained in:
Daniel Marjamäki 2017-04-15 19:00:34 +02:00
parent d44cc16b1c
commit ef416d318e
2 changed files with 16 additions and 0 deletions

View File

@ -23,6 +23,8 @@ void misra_7_3() {
int x = 12lu; // 7.3
}
#define MISRA_11_9 ((void*)0) // 11.9
void misra_12_1() {
sz = sizeof x + y; // 12.1
a = (b * c) + d;

View File

@ -262,6 +262,18 @@ def misra_12_1_sizeof(rawTokens):
else:
state = 0
def misra_11_9(data):
for directive in data.directives:
res1 = re.match(r'#define ([A-Za-z_][A-Za-z_0-9]*) (.*)', directive.str)
if not res1:
continue
name = res1.group(1)
if name == 'NULL':
continue
value = res1.group(2).replace(' ','')
if value == '((void*)0)':
reportError(directive, 11, 9)
def misra_12_1(data):
for token in data.tokenlist:
p = getPrecedence(token)
@ -696,6 +708,8 @@ for arg in sys.argv[1:]:
if cfgNumber == 1:
misra_7_1(data.rawTokens)
misra_7_3(data.rawTokens)
misra_11_9(cfg);
if cfgNumber == 1:
misra_12_1_sizeof(data.rawTokens)
misra_12_1(cfg)
misra_12_2(cfg)