Skip to content

Commit

Permalink
Fix #12198: Expect function pointers in Misra 17.7 check (#5675)
Browse files Browse the repository at this point in the history
  • Loading branch information
andymacg authored Nov 20, 2023
1 parent d09a651 commit f444696
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3333,7 +3333,9 @@ def misra_17_7(self, data):
continue
if token.str != '(' or token.astParent:
continue
if not token.previous.isName or token.previous.varId:
if not token.astOperand1 or not token.astOperand1.isName:
continue
if token.astOperand1.varId and get_function_pointer_type(token.astOperand1.variable.typeStartToken) is None:
continue
if token.valueType is None:
continue
Expand Down
3 changes: 3 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,9 @@ static void misra_17_6(int x[static 20]) {(void)x;} // 17.6
static int calculation(int x) { return x + 1; }
static void misra_17_7(void) {
calculation(123); // 17.7
int (*calc_ptr)(int) = &calculation;
calc_ptr(123); // 17.7
int y = calc_ptr(123);
}

static void misra_17_8(int x) {
Expand Down

0 comments on commit f444696

Please sign in to comment.