Fixup MISRA 5.1 (#1969)
This commit is contained in:
parent
b2c747cff6
commit
4eb362352d
|
@ -716,9 +716,8 @@ class MisraChecker:
|
||||||
if c != '"' and c != '\\':
|
if c != '"' and c != '\\':
|
||||||
self.reportError(token, 4, 1)
|
self.reportError(token, 4, 1)
|
||||||
|
|
||||||
|
|
||||||
def misra_5_1(self, data):
|
def misra_5_1(self, data):
|
||||||
varnames = []
|
long_vars = {}
|
||||||
for var in data.variables:
|
for var in data.variables:
|
||||||
if var.nameToken is None:
|
if var.nameToken is None:
|
||||||
continue
|
continue
|
||||||
|
@ -726,11 +725,13 @@ class MisraChecker:
|
||||||
continue
|
continue
|
||||||
if not hasExternalLinkage(var):
|
if not hasExternalLinkage(var):
|
||||||
continue
|
continue
|
||||||
if var.nameToken.str[:31] in varnames:
|
long_vars.setdefault(var.nameToken.str[:31], []).append(var.nameToken)
|
||||||
self.reportError(var.nameToken, 5, 1)
|
for name_prefix in long_vars:
|
||||||
else:
|
tokens = long_vars[name_prefix]
|
||||||
varnames.append(var.nameToken.str[:31])
|
if len(tokens) < 2:
|
||||||
|
continue
|
||||||
|
for tok in sorted(tokens, key=lambda t: (t.linenr, t.col))[1:]:
|
||||||
|
self.reportError(tok, 5, 1)
|
||||||
|
|
||||||
def misra_5_2(self, data):
|
def misra_5_2(self, data):
|
||||||
scopeVars = {}
|
scopeVars = {}
|
||||||
|
|
|
@ -25,7 +25,10 @@ typedef unsigned long long u64;
|
||||||
extern int misra_5_1_extern_var_hides_var_x;
|
extern int misra_5_1_extern_var_hides_var_x;
|
||||||
extern int misra_5_1_extern_var_hides_var_y; //5.1
|
extern int misra_5_1_extern_var_hides_var_y; //5.1
|
||||||
int misra_5_1_var_hides_var________a;
|
int misra_5_1_var_hides_var________a;
|
||||||
int misra_5_1_var_hides_var________b; //5.1
|
int misra_5_1_var_hides_var________b; int misra_5_1_var_hides_var________b1; int misra_5_1_var_hides_var________b2; //5.1
|
||||||
|
int misra_5_1_var_hides_var________c; //5.1
|
||||||
|
int misra_5_1_var_hides_var________d; //5.1
|
||||||
|
int misra_5_1_var_hides_var________e; //5.1
|
||||||
|
|
||||||
extern const uint8_t misra_5_2_var1;
|
extern const uint8_t misra_5_2_var1;
|
||||||
const uint8_t misra_5_2_var1 = 3; // no warning
|
const uint8_t misra_5_2_var1 = 3; // no warning
|
||||||
|
|
Loading…
Reference in New Issue