Misra: Add rule 11.4

This commit is contained in:
Daniel Marjamäki 2017-04-16 12:00:03 +02:00
parent 240b57bc9e
commit a92ce98cab
2 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,10 @@ void misra_7_3() {
int x = 12lu; // 7.3 int x = 12lu; // 7.3
} }
void misra_11_4(u8*p) {
u64 y = (u64)p; // 11.4
}
void misra_11_5(void *p) { void misra_11_5(void *p) {
x = (u8 *)p; // 11.5 x = (u8 *)p; // 11.5
} }

View File

@ -266,6 +266,17 @@ def misra_12_1_sizeof(rawTokens):
else: else:
state = 0 state = 0
def misra_11_4(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 vt2.pointer>0 and vt2.type != 'void':
reportError(token, 11, 4)
def misra_11_5(data): def misra_11_5(data):
for token in data.tokenlist: for token in data.tokenlist:
if not isCast(token): if not isCast(token):
@ -765,6 +776,7 @@ for arg in sys.argv[1:]:
if cfgNumber == 1: if cfgNumber == 1:
misra_7_1(data.rawTokens) misra_7_1(data.rawTokens)
misra_7_3(data.rawTokens) misra_7_3(data.rawTokens)
misra_11_4(cfg)
misra_11_5(cfg) misra_11_5(cfg)
misra_11_6(cfg) misra_11_6(cfg)
misra_11_7(cfg) misra_11_7(cfg)