Misra: Add rule 11.5

This commit is contained in:
Daniel Marjamäki 2017-04-16 11:47:44 +02:00
parent 657c9db478
commit 240b57bc9e
2 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,10 @@ void misra_7_3() {
int x = 12lu; // 7.3
}
void misra_11_5(void *p) {
x = (u8 *)p; // 11.5
}
void misra_11_6() {
void *p;
p = (void*)123; // 11.6

View File

@ -266,6 +266,17 @@ def misra_12_1_sizeof(rawTokens):
else:
state = 0
def misra_11_5(data):
for token in data.tokenlist:
if not isCast(token):
continue
vt1 = token.valueType
vt2 = token.astOperand1.valueType
if not vt1 or not vt2:
continue
if vt1.pointer>0 and vt1.type != 'void' and vt2.pointer==vt1.pointer and vt2.type == 'void':
reportError(token, 11, 5)
def misra_11_6(data):
for token in data.tokenlist:
if not isCast(token):
@ -754,6 +765,7 @@ for arg in sys.argv[1:]:
if cfgNumber == 1:
misra_7_1(data.rawTokens)
misra_7_3(data.rawTokens)
misra_11_5(cfg)
misra_11_6(cfg)
misra_11_7(cfg)
misra_11_8(cfg)