Fix #12198: Expect function pointers in Misra 17.7 check (#5675)

This commit is contained in:
andymacg 2023-11-20 14:19:20 -05:00 committed by GitHub
parent d09a6514cd
commit f444696d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -3333,7 +3333,9 @@ class MisraChecker:
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

View File

@ -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) {