misra: fix fp in 16.6
This commit is contained in:
parent
0a95fb4b70
commit
493e243c0b
|
@ -362,6 +362,22 @@ def isHexDigit(c):
|
||||||
def isOctalDigit(c):
|
def isOctalDigit(c):
|
||||||
return (c >= '0' and c <= '7')
|
return (c >= '0' and c <= '7')
|
||||||
|
|
||||||
|
def isNoReturnScope(tok):
|
||||||
|
if tok is None or tok.str != '}':
|
||||||
|
return False
|
||||||
|
if tok.previous is None or tok.previous.str != ';':
|
||||||
|
return False
|
||||||
|
if simpleMatch(tok.previous.previous, 'break ;'):
|
||||||
|
return True
|
||||||
|
prev = tok.previous.previous
|
||||||
|
while prev and prev.str not in ';{}':
|
||||||
|
if prev.str in '])':
|
||||||
|
prev = prev.link
|
||||||
|
prev = prev.previous
|
||||||
|
if prev and prev.next.str in ['throw', 'return']:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def misra_3_1(rawTokens):
|
def misra_3_1(rawTokens):
|
||||||
for token in rawTokens:
|
for token in rawTokens:
|
||||||
if token.str.startswith('/*') or token.str.startswith('//'):
|
if token.str.startswith('/*') or token.str.startswith('//'):
|
||||||
|
@ -1022,11 +1038,11 @@ def misra_16_6(data):
|
||||||
tok = token.next.link.next.next
|
tok = token.next.link.next.next
|
||||||
count = 0
|
count = 0
|
||||||
while tok:
|
while tok:
|
||||||
if tok.str == 'break':
|
if tok.str in ['break', 'return', 'throw']:
|
||||||
count = count + 1
|
count = count + 1
|
||||||
elif tok.str == '{':
|
elif tok.str == '{':
|
||||||
tok = tok.link
|
tok = tok.link
|
||||||
if simpleMatch(tok.previous.previous, 'break ;'):
|
if isNoReturnScope(tok):
|
||||||
count = count + 1
|
count = count + 1
|
||||||
elif tok.str == '}':
|
elif tok.str == '}':
|
||||||
break
|
break
|
||||||
|
|
|
@ -282,6 +282,14 @@ void misra_16_6() {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No 16.6 in this switch:
|
||||||
|
switch (x) {
|
||||||
|
case A: return 1; // 15.5
|
||||||
|
case B: return 1; // 15.5
|
||||||
|
case C: return 1; // 15.5
|
||||||
|
default: return 2; // 15.5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void misra_16_7() {
|
void misra_16_7() {
|
||||||
|
|
Loading…
Reference in New Issue