From 51cbbdac628e5fd8f54e7a4dd5c956a085fc9b38 Mon Sep 17 00:00:00 2001 From: Swasti Shrivastava <37058682+swasti16@users.noreply.github.com> Date: Wed, 7 Feb 2024 01:28:35 +0530 Subject: [PATCH] Fix #12417: False positive: misra-config for struct (#5954) --- addons/misra.py | 2 +- addons/test/misra/misra-test.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/misra.py b/addons/misra.py index 2208d9dc30e..f3ccd70cb0c 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3335,7 +3335,7 @@ def misra_config(self, data): continue if not tok.isName: continue - if tok.function or tok.variable or tok.varId or tok.valueType: + if tok.function or tok.variable or tok.varId or tok.valueType or tok.typeScope: continue if tok.next.str == "(" or tok.str in ["EOF"]: continue diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index e8168ed5fda..7f8445615b0 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -1355,6 +1355,16 @@ static void misra_14_4(bool b) { if (z) {} //config } +// #12417 +struct bar_12417{ int a; }; +static int foo_12417(void){ + int ret = 1; + if (sizeof(struct bar_12417) == 0U){ // no warning for misra-config + ret = 0; + } + return ret; +} + static void misra_15_1(void) { goto a1; // 15.1 a1: