misra.py: Fix false positive for rule 15.6 (#2631)

This commit is contained in:
Georgy Komarov 2020-05-07 17:54:27 +03:00 committed by GitHub
parent c0be64d694
commit 61926ed7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -1950,7 +1950,7 @@ class MisraChecker:
if token.str.startswith('//') or token.str.startswith('/*'): if token.str.startswith('//') or token.str.startswith('/*'):
continue continue
state = 0 state = 0
if token.str != '{': if token.str not in ('{', '#'):
self.reportError(tok1, 15, 6) self.reportError(tok1, 15, 6)
def misra_15_7(self, data): def misra_15_7(self, data):

View File

@ -739,6 +739,14 @@ void misra_15_6() {
(void)0; (void)0;
#endif #endif
#if A > 0x42
if (true) {
(void)0;
}
if (true)
#endif
{ (void)0; } // no-warning
do {} while (x<0); // no-warning do {} while (x<0); // no-warning
} }