From 8d88f75f0342a86142302bfbc7ac7d2b817af987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 2 Sep 2018 16:31:27 +0200 Subject: [PATCH] Fixed #8567 (False positive: MISRA RULE 20.3) --- addons/misra.py | 7 ++++++- addons/test/misra-test.c | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/misra.py b/addons/misra.py index 3fc5854f9..a4aec481d 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -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) diff --git a/addons/test/misra-test.c b/addons/test/misra-test.c index 6ce521adc..082e88d74 100644 --- a/addons/test/misra-test.c +++ b/addons/test/misra-test.c @@ -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 // no warning #include // 21.4 #include // 21.5