Skip to content

Commit 282c195

Browse files
authored
Fix #12169 (False positive: wrong misra-config variable with accessing object in memory) (#5645)
1 parent b0cde34 commit 282c195

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

.github/workflows/CI-unixish.yml

+2
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ jobs:
424424
./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety addons/test/threadsafety
425425
./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety --std=c++03 addons/test/threadsafety
426426
./cppcheck --error-exitcode=1 --inline-suppr --addon=misra addons/test/misra/crash*.c
427+
./cppcheck --error-exitcode=1 --inline-suppr --addon=misra --enable=information addons/test/misra/config*.c
428+
427429
./cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c
428430
pushd addons/test
429431
# We'll force C89 standard to enable an additional verification for

addons/misra.py

+4
Original file line numberDiff line numberDiff line change
@@ -3315,6 +3315,10 @@ def misra_config(self, data):
33153315
continue
33163316
if isKeyword(tok.str) or isStdLibId(tok.str):
33173317
continue
3318+
if tok.astParent is None:
3319+
continue
3320+
if tok.astParent.str == "." and tok.astParent.valueType:
3321+
continue
33183322
self.report_config_error(tok, "Variable '%s' is unknown" % tok.str)
33193323

33203324
def misra_17_6(self, rawTokens):

addons/test/misra/config1.c

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
struct S {
3+
uint32_t some[100];
4+
};
5+
6+
void foo( void )
7+
{
8+
if (((S *)0x8000)->some[0] != 0U) { }
9+
}
10+

0 commit comments

Comments
 (0)