syntaxErrors were not suppressable, because they were treated as InternalErrors which were thrown and catched during the checking, and normal suppression rules were not applied for those. We fix this by calling the normal reportErr() function that does suppression matching.
This commit is contained in:
parent
963008089d
commit
acd8a092f8
|
@ -426,7 +426,7 @@ bool CppCheck::checkFile(const std::string &code, const char FileName[], std::se
|
||||||
e.id,
|
e.id,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
_errorLogger.reportErr(errmsg);
|
reportErr(errmsg);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ private:
|
||||||
TEST_CASE(inlinesuppress_unusedFunction); // #4210 - unusedFunction
|
TEST_CASE(inlinesuppress_unusedFunction); // #4210 - unusedFunction
|
||||||
TEST_CASE(globalsuppress_unusedFunction); // #4946
|
TEST_CASE(globalsuppress_unusedFunction); // #4946
|
||||||
TEST_CASE(suppressionWithRelativePaths); // #4733
|
TEST_CASE(suppressionWithRelativePaths); // #4733
|
||||||
|
TEST_CASE(suppressingSyntaxErrors); // #7076
|
||||||
|
TEST_CASE(suppressingSyntaxErrorsInline); // #5917
|
||||||
}
|
}
|
||||||
|
|
||||||
void suppressionsBadId1() const {
|
void suppressionsBadId1() const {
|
||||||
|
@ -384,6 +386,30 @@ private:
|
||||||
cppCheck.check("/somewhere/test.cpp", code);
|
cppCheck.check("/somewhere/test.cpp", code);
|
||||||
ASSERT_EQUALS("",errout.str());
|
ASSERT_EQUALS("",errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void suppressingSyntaxErrors() { // syntaxErrors should be suppressable (#7076)
|
||||||
|
std::map<std::string, std::string> 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<std::string, std::string> 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)
|
REGISTER_TEST(TestSuppressions)
|
||||||
|
|
Loading…
Reference in New Issue