misra.py: Fix rule 20.2 false negative (#2534)

This commit is contained in:
Georgy Komarov 2020-02-12 19:11:57 +03:00 committed by GitHub
parent cea17acd92
commit 2138091fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -2229,7 +2229,7 @@ class MisraChecker:
for directive in data.directives:
if not directive.str.startswith('#include '):
continue
for pattern in ('\\', '//', '/*', "'"):
for pattern in ('\\', '//', '/*', ',', "'"):
if pattern in directive.str:
self.reportError(directive, 20, 2)
break

View File

@ -2,6 +2,11 @@
// ~/cppcheck/cppcheck --dump --suppress=uninitvar --suppress=uninitStructMember misra/misra-test.c --std=c89 && python3 ../misra.py -verify misra/misra-test.c.dump
#include "path\file.h" // 20.2
#include "file//.h" // 20.2
#include "file/*.h" // 20.2
#include "file'.h" // 20.2
#include <file,.h> // 20.2
#include "file,.h" // 20.2
#include /*abc*/ "file.h" // no warning
/*foo*/#include "file.h" // no warning