From d414ad8c5c82f601667c4c21e39af3a26f705ffd Mon Sep 17 00:00:00 2001 From: Andy MacGregor Date: Wed, 16 Aug 2023 12:32:05 -0400 Subject: [PATCH] Fix #11878 FP misra-c2012-18.7 on function pointer parameter with array-type args --- addons/misra.py | 5 ++++- addons/test/misra/misra-test.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/misra.py b/addons/misra.py index eaea81dfb9d..7201c27591c 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3231,7 +3231,10 @@ def misra_18_7(self, data): if token.str == '{': token = token.link - if cppcheckdata.simpleMatch(token, "[ ]"): + # skip function pointer parameter types + if token.astOperand1 is None: + pass + elif cppcheckdata.simpleMatch(token, "[ ]"): self.reportError(token, 18, 7) break token = token.next diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 2fd30c7e707..48c605364be 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -1713,6 +1713,7 @@ struct { } r18_7_struct; // 8.4 struct { uint16_t len; + int (*array_param_func_ptr)(char const *argv[], int argc); // no-warning uint8_t data_1[ 19 ]; uint8_t data_2[ ]; // 18.7 } r18_7_struct; // 8.4