Misra: Add rule 11.7
This commit is contained in:
parent
b59d46091e
commit
ccf078747a
|
@ -23,6 +23,11 @@ void misra_7_3() {
|
||||||
int x = 12lu; // 7.3
|
int x = 12lu; // 7.3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Fred {}; struct Wilma {};
|
||||||
|
void misra_11_7(struct Fred *fred) {
|
||||||
|
struct Wilma *wilma = (struct Wilma *)fred; // 11.7
|
||||||
|
}
|
||||||
|
|
||||||
char * misra_11_8(const char *str) {
|
char * misra_11_8(const char *str) {
|
||||||
return (char *)str; // 11.8
|
return (char *)str; // 11.8
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,20 @@ def misra_12_1_sizeof(rawTokens):
|
||||||
else:
|
else:
|
||||||
state = 0
|
state = 0
|
||||||
|
|
||||||
|
def misra_11_7(data):
|
||||||
|
for token in data.tokenlist:
|
||||||
|
if not isCast(token):
|
||||||
|
continue
|
||||||
|
if not token.valueType or not token.astOperand1.valueType:
|
||||||
|
continue
|
||||||
|
res1 = re.match(r'^(const )?([A-Za-z_0-9]+) \*', token.valueType)
|
||||||
|
res2 = re.match(r'^(const )?([A-Za-z_0-9]+) \*', token.astOperand1.valueType)
|
||||||
|
if not res1 or not res2:
|
||||||
|
continue
|
||||||
|
if res1.group(2) == res2.group(2):
|
||||||
|
continue
|
||||||
|
reportError(token, 11, 7)
|
||||||
|
|
||||||
def misra_11_8(data):
|
def misra_11_8(data):
|
||||||
for token in data.tokenlist:
|
for token in data.tokenlist:
|
||||||
if not isCast(token):
|
if not isCast(token):
|
||||||
|
@ -731,6 +745,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_7(cfg)
|
||||||
misra_11_8(cfg)
|
misra_11_8(cfg)
|
||||||
misra_11_9(cfg)
|
misra_11_9(cfg)
|
||||||
if cfgNumber == 1:
|
if cfgNumber == 1:
|
||||||
|
|
Loading…
Reference in New Issue