Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3157,15 +3157,15 @@ def misra_16_3(self, rawTokens):
STATE_OK = 2 # a case/default is allowed (we have seen 'break;'/'comment'/'{'/attribute)
STATE_SWITCH = 3 # walking through switch statement scope

define = None
directive = None
state = STATE_NONE
end_switch_token = None # end '}' for the switch scope
for token in rawTokens:
if simpleMatch(token, '# define'):
define = token
if define:
if token.linenr != define.linenr:
define = None
if simpleMatch(token, '# define') or simpleMatch(token, '# pragma'):
directive = token
if directive:
if token.linenr != directive.linenr:
directive = None
else:
continue

Expand Down 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 == '{'):
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