Misra: Add rule 8.11
This commit is contained in:
parent
6c8712c57b
commit
4f64e67298
|
@ -345,6 +345,7 @@ class Variable:
|
|||
isArgument Is this variable a function argument?
|
||||
isArray Is this variable an array?
|
||||
isClass Is this variable a class or struct?
|
||||
isExtern Is this variable an extern variable?
|
||||
isLocal Is this variable a local variable?
|
||||
isPointer Is this variable a pointer
|
||||
isReference Is this variable a reference
|
||||
|
@ -361,6 +362,7 @@ class Variable:
|
|||
isArgument = False
|
||||
isArray = False
|
||||
isClass = False
|
||||
isExtern = False
|
||||
isLocal = False
|
||||
isPointer = False
|
||||
isReference = False
|
||||
|
@ -377,6 +379,7 @@ class Variable:
|
|||
self.isArgument = element.get('isArgument') == 'true'
|
||||
self.isArray = element.get('isArray') == 'true'
|
||||
self.isClass = element.get('isClass') == 'true'
|
||||
self.isExtern = element.get('isExtern') == 'true'
|
||||
self.isLocal = element.get('isLocal') == 'true'
|
||||
self.isPointer = element.get('isPointer') == 'true'
|
||||
self.isReference = element.get('isReference') == 'true'
|
||||
|
|
|
@ -26,6 +26,8 @@ void misra_7_3() {
|
|||
int x = 12lu; // 7.3
|
||||
}
|
||||
|
||||
extern int a811[]; // 8.11
|
||||
|
||||
enum e812 {
|
||||
A=3,
|
||||
B=3 // 8.12
|
||||
|
|
|
@ -283,6 +283,11 @@ def misra_7_3(rawTokens):
|
|||
if re.match(r'^[0-9]+l', tok.str):
|
||||
reportError(tok, 7, 3)
|
||||
|
||||
def misra_8_11(data):
|
||||
for var in data.variables:
|
||||
if var.isExtern and simpleMatch(var.nameToken.next, '[ ]') and var.nameToken.scope.type == 'Global':
|
||||
reportError(var.nameToken, 8, 11)
|
||||
|
||||
def misra_8_12(data):
|
||||
for token in data.tokenlist:
|
||||
if token.str != '{':
|
||||
|
@ -780,9 +785,9 @@ def misra_18_5(data):
|
|||
|
||||
def misra_18_8(data):
|
||||
for var in data.variables:
|
||||
if not var.isArray:
|
||||
if not var.isArray or not var.isLocal:
|
||||
continue
|
||||
# TODO Array dimensions are not available in dump
|
||||
# TODO Array dimensions are not available in dump, must look in tokens
|
||||
typetok = var.nameToken.next
|
||||
if not typetok or typetok.str != '[':
|
||||
continue
|
||||
|
@ -934,6 +939,7 @@ for arg in sys.argv[1:]:
|
|||
if cfgNumber == 1:
|
||||
misra_7_1(data.rawTokens)
|
||||
misra_7_3(data.rawTokens)
|
||||
misra_8_11(cfg)
|
||||
misra_8_12(cfg)
|
||||
if cfgNumber == 1:
|
||||
misra_8_14(data.rawTokens)
|
||||
|
|
|
@ -2929,6 +2929,7 @@ void SymbolDatabase::printXml(std::ostream &out) const
|
|||
out << " isArgument=\"" << var->isArgument() << '\"';
|
||||
out << " isArray=\"" << var->isArray() << '\"';
|
||||
out << " isClass=\"" << var->isClass() << '\"';
|
||||
out << " isExtern=\"" << var->isExtern() << '\"';
|
||||
out << " isLocal=\"" << var->isLocal() << '\"';
|
||||
out << " isPointer=\"" << var->isPointer() << '\"';
|
||||
out << " isReference=\"" << var->isReference() << '\"';
|
||||
|
|
Loading…
Reference in New Issue