Misra: Added rule 16.5
This commit is contained in:
parent
33df403727
commit
1cd8454239
@ -144,4 +144,17 @@ void misra_16_4() {
|
|||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void misra_16_5() {
|
||||||
|
switch (x) {
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
default: // 16.5
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -459,6 +459,22 @@ def misra_16_4(data):
|
|||||||
if tok and tok.str != 'default':
|
if tok and tok.str != 'default':
|
||||||
reportError(token, 16, 4)
|
reportError(token, 16, 4)
|
||||||
|
|
||||||
|
def misra_16_5(data):
|
||||||
|
for token in data.tokenlist:
|
||||||
|
if token.str != 'default':
|
||||||
|
continue
|
||||||
|
if token.previous and token.previous.str == '{':
|
||||||
|
continue
|
||||||
|
tok2 = token
|
||||||
|
while tok2:
|
||||||
|
if tok2.str in ['}', 'case']:
|
||||||
|
break
|
||||||
|
if tok2.str == '{':
|
||||||
|
tok2 = tok2.link
|
||||||
|
tok2 = tok2.next
|
||||||
|
if tok2 and tok2.str == 'case':
|
||||||
|
reportError(token, 16, 5)
|
||||||
|
|
||||||
if '-verify' in sys.argv[1:]:
|
if '-verify' in sys.argv[1:]:
|
||||||
VERIFY = True
|
VERIFY = True
|
||||||
|
|
||||||
@ -514,6 +530,7 @@ for arg in sys.argv[1:]:
|
|||||||
if cfgNumber == 1:
|
if cfgNumber == 1:
|
||||||
misra_16_3(data.rawTokens)
|
misra_16_3(data.rawTokens)
|
||||||
misra_16_4(cfg)
|
misra_16_4(cfg)
|
||||||
|
misra_16_5(cfg)
|
||||||
|
|
||||||
if VERIFY:
|
if VERIFY:
|
||||||
for expected in VERIFY_EXPECTED:
|
for expected in VERIFY_EXPECTED:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user