Skip to content

Commit

Permalink
Fix #12418: Misra 11.6 checks cast from expression result (#5953)
Browse files Browse the repository at this point in the history
  • Loading branch information
andymacg authored Feb 12, 2024
1 parent 40552e2 commit ade6f61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2581,8 +2581,6 @@ def misra_11_6(self, data):
for token in data.tokenlist:
if not isCast(token):
continue
if token.astOperand1.astOperand1:
continue
vt1 = token.valueType
vt2 = token.astOperand1.valueType
if not vt1 or not vt2:
Expand Down
7 changes: 7 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,17 @@ static void misra_11_5(void *p) {
p16 = p; // 11.5
}

static intptr_t get_intptr_constant(void) { return 456; }
static void misra_11_6(void) {
void *p;
struct {
int i;
} s = { .i = 7 };
p = (void*)123; // 11.6
x = (u64)p; // 11.6
p = (void*)(1+1);// 11.6
p = (void*)get_intptr_constant(); // 11.6
p = (void*)s.i; // 11.6
p = ( void * )0; // no-warning
(void)p; // no-warning
// # 12184
Expand Down

0 comments on commit ade6f61

Please sign in to comment.