diff --git a/addons/misra.py b/addons/misra.py index f6e0698df0e..cc26146dd10 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -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 diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 14eddd8600c..db73cfd6466 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -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) {