Fixed #8823 (false positive: MISRA rule 16.3)
This commit is contained in:
parent
db57769c64
commit
2e9e3ed2f1
|
@ -1519,8 +1519,12 @@ class MisraChecker:
|
||||||
state = STATE_OK
|
state = STATE_OK
|
||||||
elif token.str == '}' and state == STATE_OK:
|
elif token.str == '}' and state == STATE_OK:
|
||||||
# is this {} an unconditional block of code?
|
# is this {} an unconditional block of code?
|
||||||
link = findRawLink(token)
|
prev = findRawLink(token)
|
||||||
if (link is None) or (link.previous is None) or (link.previous.str not in ':;{}'):
|
if prev:
|
||||||
|
prev = prev.previous
|
||||||
|
while prev and prev.str[:2] in ('//', '/*'):
|
||||||
|
prev = prev.previous
|
||||||
|
if (prev is None) or (prev.str not in ':;{}'):
|
||||||
state = STATE_NONE
|
state = STATE_NONE
|
||||||
elif token.str == 'case' or token.str == 'default':
|
elif token.str == 'case' or token.str == 'default':
|
||||||
if state != STATE_OK:
|
if state != STATE_OK:
|
||||||
|
|
|
@ -441,6 +441,23 @@ void misra_16_3() {
|
||||||
case 12:
|
case 12:
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
case 1: // comment 1
|
||||||
|
{
|
||||||
|
a = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: // comment 2
|
||||||
|
{
|
||||||
|
a = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void misra_16_4() {
|
void misra_16_4() {
|
||||||
|
|
Loading…
Reference in New Issue