diff --git a/addons/misra.py b/addons/misra.py index c4136afbf..be3e0ed4e 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # # MISRA C 2012 checkers +# Partially reused for "MISRA C++ 2008" checking # # Example usage of this addon (scan a sourcefile main.cpp) # cppcheck --dump main.cpp @@ -4208,7 +4209,8 @@ class MisraChecker: :param args: Check function arguments """ if not self.isRuleGloballySuppressed(rule_num): - check_function(*args) + if (not self.is_cpp) or rule_num in (202,203,1901): + check_function(*args) def parseDump(self, dumpfile): def fillVerifyExpected(verify_expected, tok): @@ -4249,6 +4251,8 @@ class MisraChecker: else: self.printStatus('Checking ' + dumpfile + '...') + self.is_cpp = data.files and data.files[0].endswith('.cpp') + for cfgNumber, cfg in enumerate(data.iterconfigurations()): if not self.settings.quiet: self.printStatus('Checking %s, config %s...' % (dumpfile, cfg.name)) diff --git a/addons/test/misra/misra-test.cpp b/addons/test/misra/misra-test.cpp index ce322326f..52c35a0fe 100644 --- a/addons/test/misra/misra-test.cpp +++ b/addons/test/misra/misra-test.cpp @@ -7,7 +7,7 @@ class C { class misra_21_1_C { public: - misra_21_1_C operator=(const misra_21_1_C &); // 8.2 + misra_21_1_C operator=(const misra_21_1_C &); }; class C2 { @@ -20,6 +20,6 @@ C2::C2(void) : f(NULL) {} static void test_misra_21_1_crash(void) { - auto misra_21_1_C a, b; // 12.3 + auto misra_21_1_C a, b; a = b; }