Fixed #8567 (False positive: MISRA RULE 20.3)

This commit is contained in:
Daniel Marjamäki 2018-09-02 16:31:27 +02:00
parent 8f9fa2e6a7
commit 8d88f75f03
2 changed files with 8 additions and 2 deletions

View File

@ -1476,7 +1476,12 @@ def misra_20_3(rawTokens):
if not simpleMatch(token, '# include'):
continue
headerToken = token.next.next
if not headerToken or not (headerToken.str.startswith('<') or headerToken.str.startswith('"')):
num = 0
while headerToken and headerToken.linenr == linenr:
if not headerToken.str.startswith('/*') and not headerToken.str.startswith('//'):
num += 1
headerToken = headerToken.next
if num != 1:
reportError(token, 20, 3)

View File

@ -2,7 +2,8 @@
// ~/cppcheck/cppcheck --dump misra-test.c && python ../misra.py -verify misra-test.c.dump
#include "path\file.h" // 20.2
#include /*abc*/ "file.h" // 20.3
#include /*abc*/ "file.h" // no warning
#include PATH "file.h" // 20.3
#include<file.h> // no warning
#include <setjmp.h> // 21.4
#include <signal.h> // 21.5