Misra: Added rule 17.1
This commit is contained in:
parent
e5286c61d5
commit
41e07c0614
|
@ -534,6 +534,11 @@ class CppcheckData:
|
||||||
tok = Token(node)
|
tok = Token(node)
|
||||||
tok.file = files[int(node.get('fileIndex'))]
|
tok.file = files[int(node.get('fileIndex'))]
|
||||||
self.rawTokens.append(tok)
|
self.rawTokens.append(tok)
|
||||||
|
for i in range(len(self.rawTokens)):
|
||||||
|
if i > 0:
|
||||||
|
self.rawTokens[i].previous = self.rawTokens[i-1]
|
||||||
|
if i + 1 < len(self.rawTokens):
|
||||||
|
self.rawTokens[i].next = self.rawTokens[i+1]
|
||||||
|
|
||||||
|
|
||||||
# root is 'dumps' node, each config has its own 'dump' subnode.
|
# root is 'dumps' node, each config has its own 'dump' subnode.
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// To test:
|
// To test:
|
||||||
// ~/cppcheck/cppcheck --dump misra-test.c && python misra.py -verify misra-test.c.dump
|
// ~/cppcheck/cppcheck --dump misra-test.c && python misra.py -verify misra-test.c.dump
|
||||||
|
|
||||||
|
#include <stdarg.h> // 17.1
|
||||||
|
|
||||||
typedef unsigned char u8;
|
typedef unsigned char u8;
|
||||||
|
|
||||||
void misra_5_1() {
|
void misra_5_1() {
|
||||||
|
@ -172,3 +174,5 @@ void misra_16_7() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -497,6 +497,11 @@ def misra_16_7(data):
|
||||||
if simpleMatch(token, 'switch (') and isBoolExpression(token.next.astOperand2):
|
if simpleMatch(token, 'switch (') and isBoolExpression(token.next.astOperand2):
|
||||||
reportError(token, 16, 7)
|
reportError(token, 16, 7)
|
||||||
|
|
||||||
|
def misra_17_1(rawTokens):
|
||||||
|
for token in rawTokens:
|
||||||
|
if simpleMatch(token, '# include <stdarg.h>'):
|
||||||
|
reportError(token, 17, 1)
|
||||||
|
|
||||||
|
|
||||||
if '-verify' in sys.argv[1:]:
|
if '-verify' in sys.argv[1:]:
|
||||||
VERIFY = True
|
VERIFY = True
|
||||||
|
@ -556,6 +561,8 @@ for arg in sys.argv[1:]:
|
||||||
misra_16_5(cfg)
|
misra_16_5(cfg)
|
||||||
misra_16_6(cfg)
|
misra_16_6(cfg)
|
||||||
misra_16_7(cfg)
|
misra_16_7(cfg)
|
||||||
|
if cfgNumber == 1:
|
||||||
|
misra_17_1(data.rawTokens)
|
||||||
|
|
||||||
if VERIFY:
|
if VERIFY:
|
||||||
for expected in VERIFY_EXPECTED:
|
for expected in VERIFY_EXPECTED:
|
||||||
|
|
Loading…
Reference in New Issue