Misra: Add rule 20.2
This commit is contained in:
parent
3c11aa781b
commit
79ef26d7a2
|
@ -2,6 +2,7 @@
|
|||
// ~/cppcheck/cppcheck --dump misra-test.c && python misra.py -verify misra-test.c.dump
|
||||
|
||||
#include <stdarg.h> // 17.1
|
||||
#include "path\file.h" // 20.2
|
||||
|
||||
typedef unsigned char u8;
|
||||
|
||||
|
|
|
@ -564,6 +564,16 @@ def misra_20_1(rawTokens):
|
|||
elif state == 2 and simpleMatch(token, '# include'):
|
||||
reportError(token, 20, 1)
|
||||
|
||||
def misra_20_2(rawTokens):
|
||||
for token in rawTokens:
|
||||
if not simpleMatch(token, '# include'):
|
||||
continue
|
||||
header = token.next.next.str
|
||||
for pattern in ['\\', '//', '/*', '\'']:
|
||||
if header.find(pattern)>0:
|
||||
reportError(token, 20, 2)
|
||||
break
|
||||
|
||||
if '-verify' in sys.argv[1:]:
|
||||
VERIFY = True
|
||||
|
||||
|
@ -631,6 +641,7 @@ for arg in sys.argv[1:]:
|
|||
misra_19_2(cfg)
|
||||
if cfgNumber == 1:
|
||||
misra_20_1(data.rawTokens)
|
||||
misra_20_2(data.rawTokens)
|
||||
|
||||
if VERIFY:
|
||||
for expected in VERIFY_EXPECTED:
|
||||
|
|
Loading…
Reference in New Issue