Skip to content

Commit

Permalink
Fix #12169 (False positive: wrong misra-config variable with accessin…
Browse files Browse the repository at this point in the history
…g object in memory) (danmar#5645)
  • Loading branch information
danmar authored Nov 9, 2023
1 parent b0cde34 commit 282c195
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 10 additions & 0 deletions addons/test/misra/config1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

struct S {
uint32_t some[100];
};

void foo( void )
{
if (((S *)0x8000)->some[0] != 0U) { }
}

0 comments on commit 282c195

Please sign in to comment.