Misra: Add rule 20.2

This commit is contained in:
Daniel Marjamäki 2017-04-14 22:22:22 +02:00
parent 3c11aa781b
commit 79ef26d7a2
2 changed files with 12 additions and 0 deletions

View File

@ -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;

View File

@ -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: