Skip to content

Commit

Permalink
Fix 12448: False positive: misra-config about unknown variable after …
Browse files Browse the repository at this point in the history
…struct keyword
  • Loading branch information
swasti16 committed Feb 17, 2024
1 parent 95235ca commit c972140
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3342,7 +3342,15 @@ def misra_config(self, data):
continue
if tok.astParent.str == "." and tok.astParent.valueType:
continue
self.report_config_error(tok, "Variable '%s' is unknown" % tok.str)
tok_pre = tok.previous
name = False
while tok_pre.isName or tok_pre.str == "*":
if tok_pre.str != '*':
name = True
break
tok_pre = tok_pre.previous
if not name:
self.report_config_error(tok, "Variable '%s' is unknown" % tok.str)

def misra_17_6(self, rawTokens):
for token in rawTokens:
Expand Down
10 changes: 10 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,3 +2035,13 @@ static void misra_22_10(void)
f = strtod(inStr, NULL_PTR);
if(errno != 0) {}
}

// #12448
static void check_misra_config(void)
{
if (sizeof(struct bar) == 0U) {} //no warning
if (sizeof(int abc) == 0U) {} //no warning
if (sizeof(xyz) == 0U) {} //config
if (sizeof(const pqr) == 0U) {} //no warning
if (sizeof(const int* const pqrs) == 0U) {} //no-warning
}

0 comments on commit c972140

Please sign in to comment.