Misra: Add rule 11.8
This commit is contained in:
parent
dd8b96f4c8
commit
b59d46091e
|
@ -73,6 +73,7 @@ class Token:
|
||||||
function If this token points at a function call, this attribute has the Function
|
function If this token points at a function call, this attribute has the Function
|
||||||
information. See the Function class.
|
information. See the Function class.
|
||||||
values Possible values of token
|
values Possible values of token
|
||||||
|
valueType type information
|
||||||
typeScope type scope (token->type()->classScope)
|
typeScope type scope (token->type()->classScope)
|
||||||
astParent ast parent
|
astParent ast parent
|
||||||
astOperand1 ast operand1
|
astOperand1 ast operand1
|
||||||
|
@ -121,6 +122,7 @@ class Token:
|
||||||
function = None
|
function = None
|
||||||
valuesId = None
|
valuesId = None
|
||||||
values = None
|
values = None
|
||||||
|
valueType = None
|
||||||
|
|
||||||
typeScopeId = None
|
typeScopeId = None
|
||||||
typeScope = None
|
typeScope = None
|
||||||
|
@ -179,6 +181,7 @@ class Token:
|
||||||
self.function = None
|
self.function = None
|
||||||
self.valuesId = element.get('values')
|
self.valuesId = element.get('values')
|
||||||
self.values = None
|
self.values = None
|
||||||
|
self.valueType = element.get('valueType')
|
||||||
self.typeScopeId = element.get('type-scope')
|
self.typeScopeId = element.get('type-scope')
|
||||||
self.typeScope = None
|
self.typeScope = None
|
||||||
self.astParentId = element.get('astParent')
|
self.astParentId = element.get('astParent')
|
||||||
|
|
|
@ -23,6 +23,10 @@ void misra_7_3() {
|
||||||
int x = 12lu; // 7.3
|
int x = 12lu; // 7.3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * misra_11_8(const char *str) {
|
||||||
|
return (char *)str; // 11.8
|
||||||
|
}
|
||||||
|
|
||||||
#define MISRA_11_9 ((void*)0) // 11.9
|
#define MISRA_11_9 ((void*)0) // 11.9
|
||||||
|
|
||||||
void misra_12_1() {
|
void misra_12_1() {
|
||||||
|
|
|
@ -96,6 +96,9 @@ def bitsOfEssentialType(expr):
|
||||||
return INT_BIT
|
return INT_BIT
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def isCast(expr):
|
||||||
|
return expr and expr.str == '(' and expr.astOperand1 == expr.link.next
|
||||||
|
|
||||||
def isFunctionCall(expr):
|
def isFunctionCall(expr):
|
||||||
if not expr:
|
if not expr:
|
||||||
return False
|
return False
|
||||||
|
@ -263,6 +266,18 @@ def misra_12_1_sizeof(rawTokens):
|
||||||
else:
|
else:
|
||||||
state = 0
|
state = 0
|
||||||
|
|
||||||
|
def misra_11_8(data):
|
||||||
|
for token in data.tokenlist:
|
||||||
|
if not isCast(token):
|
||||||
|
continue
|
||||||
|
if not token.valueType or not token.astOperand1.valueType:
|
||||||
|
continue
|
||||||
|
if token.valueType.startswith('const') or not token.astOperand1.valueType.startswith('const'):
|
||||||
|
continue
|
||||||
|
if token.valueType.find('*')<0 or token.astOperand1.valueType.find('*')<0:
|
||||||
|
continue
|
||||||
|
reportError(token, 11, 8)
|
||||||
|
|
||||||
def misra_11_9(data):
|
def misra_11_9(data):
|
||||||
for directive in data.directives:
|
for directive in data.directives:
|
||||||
res1 = re.match(r'#define ([A-Za-z_][A-Za-z_0-9]*) (.*)', directive.str)
|
res1 = re.match(r'#define ([A-Za-z_][A-Za-z_0-9]*) (.*)', directive.str)
|
||||||
|
@ -716,7 +731,8 @@ 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_9(cfg);
|
misra_11_8(cfg)
|
||||||
|
misra_11_9(cfg)
|
||||||
if cfgNumber == 1:
|
if cfgNumber == 1:
|
||||||
misra_12_1_sizeof(data.rawTokens)
|
misra_12_1_sizeof(data.rawTokens)
|
||||||
misra_12_1(cfg)
|
misra_12_1(cfg)
|
||||||
|
|
Loading…
Reference in New Issue