Skip to content

Commit ade6f61

Browse files
Fix #12418: Misra 11.6 checks cast from expression result (#5953)
1 parent 40552e2 commit ade6f61

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

addons/misra.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,8 +2581,6 @@ def misra_11_6(self, data):
25812581
for token in data.tokenlist:
25822582
if not isCast(token):
25832583
continue
2584-
if token.astOperand1.astOperand1:
2585-
continue
25862584
vt1 = token.valueType
25872585
vt2 = token.astOperand1.valueType
25882586
if not vt1 or not vt2:

addons/test/misra/misra-test.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,17 @@ static void misra_11_5(void *p) {
836836
p16 = p; // 11.5
837837
}
838838

839+
static intptr_t get_intptr_constant(void) { return 456; }
839840
static void misra_11_6(void) {
840841
void *p;
842+
struct {
843+
int i;
844+
} s = { .i = 7 };
841845
p = (void*)123; // 11.6
842846
x = (u64)p; // 11.6
847+
p = (void*)(1+1);// 11.6
848+
p = (void*)get_intptr_constant(); // 11.6
849+
p = (void*)s.i; // 11.6
843850
p = ( void * )0; // no-warning
844851
(void)p; // no-warning
845852
// # 12184

0 commit comments

Comments
 (0)