diff --git a/addons/misra.py b/addons/misra.py index 7b93c1e3f..67928434f 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -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 != "=": diff --git a/addons/test/misra-test.c b/addons/test/misra-test.c index 7ba4e3be0..0fd22a59f 100644 --- a/addons/test/misra-test.c +++ b/addons/test/misra-test.c @@ -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