diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 6288fe1b1da..24d4de1faf5 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -424,6 +424,8 @@ jobs: ./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety addons/test/threadsafety ./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety --std=c++03 addons/test/threadsafety ./cppcheck --error-exitcode=1 --inline-suppr --addon=misra addons/test/misra/crash*.c + ./cppcheck --error-exitcode=1 --inline-suppr --addon=misra --enable=information addons/test/misra/config*.c + ./cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c pushd addons/test # We'll force C89 standard to enable an additional verification for diff --git a/addons/misra.py b/addons/misra.py index b09c2ff8ae9..48b6e0a59f9 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3315,6 +3315,10 @@ def misra_config(self, data): continue if isKeyword(tok.str) or isStdLibId(tok.str): continue + if tok.astParent is None: + continue + if tok.astParent.str == "." and tok.astParent.valueType: + continue self.report_config_error(tok, "Variable '%s' is unknown" % tok.str) def misra_17_6(self, rawTokens): diff --git a/addons/test/misra/config1.c b/addons/test/misra/config1.c new file mode 100644 index 00000000000..31aa2a4d6b5 --- /dev/null +++ b/addons/test/misra/config1.c @@ -0,0 +1,10 @@ + +struct S { + uint32_t some[100]; +}; + +void foo( void ) +{ + if (((S *)0x8000)->some[0] != 0U) { } +} +