Skip to content

Commit

Permalink
Fix #13648: False positive: Misra C 16.5: warn on default in macro
Browse files Browse the repository at this point in the history
  • Loading branch information
olabetskyi committed Feb 21, 2025
1 parent 70a1e08 commit 880f496
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3231,7 +3231,7 @@ def misra_16_5(self, data):
for token in data.tokenlist:
if token.str != 'default':
continue
if token.previous and token.previous.str == '{':
if token.previous and (token.previous.str == '{' or token.previous.str == '='):
continue
tok2 = token
while tok2:
Expand Down
2 changes: 2 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// ~/cppcheck/cppcheck --dump misra/misra-test.h --std=c89
// ~/cppcheck/cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 && python3 ../misra.py -verify misra/misra-test.c.dump

#pragma ghs section rodata=default // no warning

#include "path\file.h" // 20.2
#include "file//.h" // 20.2
#include "file/*.h" // 20.2
Expand Down

0 comments on commit 880f496

Please sign in to comment.