Fix #12169 (False positive: wrong misra-config variable with accessing object in memory) (#5645)

This commit is contained in:
Daniel Marjamäki 2023-11-09 12:25:42 +01:00 committed by GitHub
parent b0cde34d1a
commit 282c195a6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -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

View File

@ -3315,6 +3315,10 @@ class MisraChecker:
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):

View File

@ -0,0 +1,10 @@
struct S {
uint32_t some[100];
};
void foo( void )
{
if (((S *)0x8000)->some[0] != 0U) { }
}