diff --git a/addons/misra.py b/addons/misra.py index a48629b986f..14a17703596 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -2291,10 +2291,9 @@ def get_category(essential_type): rhs_category = get_category(rhs) if lhs_category and rhs_category and lhs_category != rhs_category and rhs_category not in ('signed','unsigned'): self.reportError(tok, 10, 3) - if bitsOfEssentialType(lhs) < bitsOfEssentialType(rhs): + if bitsOfEssentialType(lhs) < bitsOfEssentialType(rhs) and (lhs != "bool" or tok.astOperand2.str not in ('0','1')): self.reportError(tok, 10, 3) - def misra_10_4(self, data): op = {'+', '-', '*', '/', '%', '&', '|', '^', '+=', '-=', ':'} for token in data.tokenlist: diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 2afa7b8cfec..da9243cf0b7 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -712,6 +712,7 @@ static void misra_10_3(uint32_t u32a, uint32_t u32b) { res = 2U + 3U; // no warning, utlr=unsigned char res = 0.1f; // 10.3 const char c = '0'; // no-warning + bool b = true; // no-warning uint32_t u = UINT32_C(10); // no-warning }