From d7b600ccf893480eb393e5f6f46d1ce868402aed Mon Sep 17 00:00:00 2001 From: swasti16 Date: Wed, 7 Feb 2024 00:03:06 +0530 Subject: [PATCH] Fix #12417: False positive: misra-config for struct --- 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 14a17703596..2e4b05d06f5 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3334,7 +3334,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 da9243cf0b7..0bb90de37c4 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -1357,6 +1357,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: