Fixed #8658 (false positive: MISRA rule 8.12)

This commit is contained in:
Daniel Marjamäki 2019-06-01 13:10:20 +02:00
parent bee248b2de
commit 7c6d15bb81
2 changed files with 10 additions and 5 deletions

View File

@ -865,15 +865,19 @@ class MisraChecker:
def misra_8_12(self, data):
for scope in data.scopes:
enum_values = []
implicit_enum_values = []
if scope.type != 'Enum':
continue
enum_values = []
implicit_enum_values = []
e_token = scope.bodyStart.next
while e_token != scope.bodyEnd:
if e_token.isName and \
e_token.values and \
e_token.valueType and e_token.valueType.typeScope == scope:
if e_token.str == '(':
e_token.str == e_token.link
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]
enum_values += token_values
if e_token.next.str != "=":

View File

@ -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_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_d { misra_d1 = 1, misra_d2 = 2, misra_d3 = misra_d1 }; // no-warning
void misra_8_14(char * restrict str) {} // 8.14