Fixed #8658 (false positive: MISRA rule 8.12)
This commit is contained in:
parent
bee248b2de
commit
7c6d15bb81
|
@ -865,15 +865,19 @@ class MisraChecker:
|
||||||
|
|
||||||
def misra_8_12(self, data):
|
def misra_8_12(self, data):
|
||||||
for scope in data.scopes:
|
for scope in data.scopes:
|
||||||
enum_values = []
|
|
||||||
implicit_enum_values = []
|
|
||||||
if scope.type != 'Enum':
|
if scope.type != 'Enum':
|
||||||
continue
|
continue
|
||||||
|
enum_values = []
|
||||||
|
implicit_enum_values = []
|
||||||
e_token = scope.bodyStart.next
|
e_token = scope.bodyStart.next
|
||||||
while e_token != scope.bodyEnd:
|
while e_token != scope.bodyEnd:
|
||||||
if e_token.isName and \
|
if e_token.str == '(':
|
||||||
e_token.values and \
|
e_token.str == e_token.link
|
||||||
e_token.valueType and e_token.valueType.typeScope == scope:
|
continue
|
||||||
|
if not e_token.previous.str in ',{':
|
||||||
|
e_token = e_token.next
|
||||||
|
continue
|
||||||
|
if e_token.isName and e_token.values and e_token.valueType and e_token.valueType.typeScope == scope:
|
||||||
token_values = [v.intvalue for v in e_token.values]
|
token_values = [v.intvalue for v in e_token.values]
|
||||||
enum_values += token_values
|
enum_values += token_values
|
||||||
if e_token.next.str != "=":
|
if e_token.next.str != "=":
|
||||||
|
|
|
@ -149,6 +149,7 @@ extern int a811[]; // 8.11
|
||||||
enum misra_8_12_a { misra_a1 = 1, misra_a2 = 2, misra_a3, misra_a4 = 3 }; //8.12
|
enum misra_8_12_a { misra_a1 = 1, misra_a2 = 2, misra_a3, misra_a4 = 3 }; //8.12
|
||||||
enum misra_8_12_b { misra_b1, misra_b2, misra_b3 = 3, misra_b4 = 3 }; // no-warning
|
enum misra_8_12_b { misra_b1, misra_b2, misra_b3 = 3, misra_b4 = 3 }; // no-warning
|
||||||
enum misra_8_12_c { misra_c1 = misra_a1, misra_c2 = 1 }; // no-warning
|
enum misra_8_12_c { misra_c1 = misra_a1, misra_c2 = 1 }; // no-warning
|
||||||
|
enum misra_8_12_d { misra_d1 = 1, misra_d2 = 2, misra_d3 = misra_d1 }; // no-warning
|
||||||
|
|
||||||
void misra_8_14(char * restrict str) {} // 8.14
|
void misra_8_14(char * restrict str) {} // 8.14
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue