diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9353cde79..694207da7 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -426,7 +426,7 @@ bool CppCheck::checkFile(const std::string &code, const char FileName[], std::se e.id, false); - _errorLogger.reportErr(errmsg); + reportErr(errmsg); } return true; } diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index a331273d4..345d2cd1f 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -46,6 +46,8 @@ private: TEST_CASE(inlinesuppress_unusedFunction); // #4210 - unusedFunction TEST_CASE(globalsuppress_unusedFunction); // #4946 TEST_CASE(suppressionWithRelativePaths); // #4733 + TEST_CASE(suppressingSyntaxErrors); // #7076 + TEST_CASE(suppressingSyntaxErrorsInline); // #5917 } void suppressionsBadId1() const { @@ -384,6 +386,30 @@ private: cppCheck.check("/somewhere/test.cpp", code); ASSERT_EQUALS("",errout.str()); } + + void suppressingSyntaxErrors() { // syntaxErrors should be suppressable (#7076) + std::map files; + files["test.cpp"] = "if if\n"; + + checkSuppression(files, "syntaxError:test.cpp:1"); + ASSERT_EQUALS("", errout.str()); + } + + void suppressingSyntaxErrorsInline() { // syntaxErrors should be suppressable (#5917) + std::map files; + files["test.cpp"] = "double result(0.0);\n" + "_asm\n" + "{\n" + " // cppcheck-suppress syntaxError\n" + " push EAX ; save EAX for callers \n" + " mov EAX,Real10 ; get the address pointed to by Real10\n" + " fld TBYTE PTR [EAX] ; load an extended real (10 bytes)\n" + " fstp QWORD PTR result ; store a double (8 bytes)\n" + " pop EAX ; restore EAX\n" + "}"; + checkSuppression(files, ""); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestSuppressions)