Skip to content

Commit f444696

Browse files
Fix #12198: Expect function pointers in Misra 17.7 check (#5675)
1 parent d09a651 commit f444696

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

addons/misra.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3333,7 +3333,9 @@ def misra_17_7(self, data):
33333333
continue
33343334
if token.str != '(' or token.astParent:
33353335
continue
3336-
if not token.previous.isName or token.previous.varId:
3336+
if not token.astOperand1 or not token.astOperand1.isName:
3337+
continue
3338+
if token.astOperand1.varId and get_function_pointer_type(token.astOperand1.variable.typeStartToken) is None:
33373339
continue
33383340
if token.valueType is None:
33393341
continue

addons/test/misra/misra-test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,9 @@ static void misra_17_6(int x[static 20]) {(void)x;} // 17.6
17391739
static int calculation(int x) { return x + 1; }
17401740
static void misra_17_7(void) {
17411741
calculation(123); // 17.7
1742+
int (*calc_ptr)(int) = &calculation;
1743+
calc_ptr(123); // 17.7
1744+
int y = calc_ptr(123);
17421745
}
17431746

17441747
static void misra_17_8(int x) {

0 commit comments

Comments
 (0)