Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12413 ( False positive on Misra 10.3 for bools ) #5948

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Loading